mathematics

[LeetCode] Integer Break

Problem Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the max […]

[LeetCode] Number of Digit One

Problem Given an integer n, count the total number of digit 1 appearing in all non-negative integers less than or equal to n. For example: Given n = 1 […]

[LeetCode] Palindrome Number

Problem Determine whether an integer is a palindrome. Do this without extra space. click to show spoilers. Some hints:Could negative integers be palin […]

[LeetCode] Valid Perfect Square

Problem Given a positive integer num, write a function which returns True if num is a perfect square else False. Note Do not use any built-in library […]

[LeetCode] Count Primes

Problem Count the number of prime numbers less than a non-negative number, n. Note 用陣列flag標記非質數，每當出現一個flag[i]為false，計數器count加一。關於質數有三點： 大於3的質數一定是奇數，如3 […]

[LintCode] Three Distinct Factors

Problem Given a positive integer n (1 <= n <= 10^18). Check whether a number has exactly three distinct factors, return true if it has exactly t […]

[LintCode] Kth Prime Number

Problem Given the prime number n, output the number of prime numbers Notice n <= 100000The prime number is defined as a natural number greater than […]