The set S originally contains numbers from 1 to n. But unfortunately, due to the data error, one of the numbers in the set got duplicated to another n......

Write an algorithm to determine if a number is "happy". A happy number is a number defined by the following process: Starting with any positive intege......

Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. For example: Given num = 38, the process is like:......

Given an integer, write a function to determine if it is a power of two. class Solution { public boolean isPowerOfTwo(int n) { if(n == 0) return false......

Write a program to check whether a given number is an ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For exa......

We define the Perfect Number is a positive integer that is equal to the sum of all its positive divisors except itself. Now, given an integer n, write......

Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in logarithmic time complexity. 这道题最好用数学解法，如果末尾为0，那么必然2*......

Given a non-negative integer c, your task is to decide whether there're two integers a and b such that a2 + b2 = c. Example 1: Input: 5 Output: True E......

Given an m * n matrix M initialized with all 0's and several update operations. Operations are represented by a 2D array, and each operation is repres......

Given an integer, write a function to determine if it is a power of three. Follow up: Could you do it without using any loop / recursion? 这题要能面试到，我吃屎。......