
leetcode
文章平均质量分 54
knight3396
这个作者很懒,什么都没留下…
展开
-
Leetcode 204 Count Primes
Description:Count the number of prime numbers less than a non-negative number, n.求小于n的素数的数量。 最传统的做法就是做一个判定函数,从2开始到n判断,看有多少素数。判定素数的方法就是从2到根号n,看看是不是可以被n整除。但是看了提示后,发现还有别的便捷的方法来解,就是原始的Sieve of Eratosthene原创 2015-06-06 20:06:06 · 415 阅读 · 0 评论 -
Leetcode 201 Bitwise AND of Numbers Range
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, 7], you should return 4.原创 2015-05-25 15:58:31 · 503 阅读 · 0 评论 -
LeetCode 207 Course Schedule
There are a total of n courses you have to take, labeled from 0 to n - 1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a pair:原创 2015-07-09 11:54:18 · 391 阅读 · 0 评论 -
LeetCode 208 Implement Trie (Prefix Tree)
Implement a trie with insert, search, and startsWith methods.Note: You may assume that all inputs are consist of lowercase letters a-z.这个题比较简单,就是实现一个单词树,单词树的相关资料可以参考:http://www.cppblog.com/yuyang7/arc原创 2015-07-09 16:39:05 · 403 阅读 · 0 评论