LeetCode Count Primes Description: Count the number of prime numbers less than a non-negative number, n. Credits: Special thanks to @mithmatt for adding this problem and creating all test cases. Hint: Let's start with a isPrime function. To determine... Read More

# Tag Archives: 数论

# LeetCode Factorial Trailing Zeroes

LeetCode Factorial Trailing Zeroes Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in logarithmic time... Read More

# LeetCode Valid Perfect Square

LeetCode Valid Perfect Square 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 function such as sqrt. Example 1: Input: 16 Returns: True Example 2: Input:... Read More

# LeetCode Single Number III

LeetCode Single Number III Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once. For example: Given nums = , return . Note: The... Read More

# LeetCode Excel Sheet Column Number

LeetCode Excel Sheet Column Number Related to question Excel Sheet Column Title Given a column title as appear in an Excel sheet, return its corresponding column number. For example: A -> 1 B -> 2 C -> 3 ... Z ->... Read More

# LeetCode Excel Sheet Column Title

LeetCode Excel Sheet Column Title Given a positive integer, return its corresponding column title as appear in an Excel sheet. For example: 1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -> AA 28 ->... Read More

# LeetCode Single Number

LeetCode Single Number Given an array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it without using extra... Read More

# LeetCode Majority Element II

LeetCode Majority Element II Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times. The algorithm should run in linear time and in O(1) space. Hint: How many majority elements could it possibly have? Do you have a... Read More

# LeetCode Majority Element

LeetCode Majority Element Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that the array is non-empty and the majority element always exist in the... Read More

# LeetCode Pascal's Triangle II

LeetCode Pascal's Triangle II Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3, Return . Note: Could you optimize your algorithm to use only O(k) extra space? 本题在LeetCode Pascal's... Read More