摘要:
Description: Count the number of prime numbers less than a non-negative number, n. 题解:就是线性筛素数的模板题。 阅读全文
摘要:
Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers in this range, inclusive. For example, given the range [5, 阅读全文
摘要:
Remove all elements from a linked list of integers that have value val. ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6Return: 1 --> 2 -- 阅读全文
摘要:
题意:把一个链表倒过来。 题解:有递归和非递归两种方式,主要就是考察指针操作的熟悉程度。 递归的方法: 非递归:就一个一个转过来方向就好了。转的时候需要用两个辅助指针,一个指向该节点的前一个节点,一个指向后一个节点。 阅读全文
摘要:
Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic if the characters in s can be replaced to get t. All occurrenc 阅读全文
摘要:
Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacen 阅读全文
摘要:
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 阅读全文