标签 “math” 下的文章

645. Set Mismatch

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......

阅读全文 »

202. Happy Number

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......

阅读全文 »

258. Add Digits

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:......

阅读全文 »

231. Power of Two

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......

阅读全文 »

263. Ugly Number

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......

阅读全文 »

507. Perfect Number

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......

阅读全文 »

326. Power of Three

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? 这题要能面试到,我吃屎。......

阅读全文 »