###### leetcode-204 Count Primes

Count the number of prime numbers less than a non-negative number, n.

https://leetcode.com/discuss/42097/short-c-sieve-of-eratosthenes-solution

class Solution {
public:
int countPrimes(int n) {
vector<bool> prime(n, true);
prime[0] = false, prime[1] = false;
for (int i = 0; i < sqrt(n); ++i) {
if (prime[i]) {
for (int j = i*i; j < n; j += i) {
prime[j] = false;
}
}
}
return count(prime.begin(), prime.end(), true);
}
};

#### LeetCode (36) Count Primes

2015-05-07 15:32:12

#### LeetCode 204 - Count Primes

2015-04-27 15:33:15

#### LeetCode 204. Count Primes（C++版）

2017-03-30 17:04:12

#### [leetcode]Count Primes C语言

2015-08-30 14:44:11

#### leetcode笔记：Count Primes

2016-01-27 23:05:58

#### LeetCode 204:Count Primes

2015-05-08 18:40:26

#### leetcode 204: Count Primes

2015-04-29 08:33:10

#### 【LeetCode-面试算法经典-Java实现】【204-Count Primes（统计质数）】

2015-08-27 06:30:01

#### Python 刷题日记：LeetCode 204: Count Primes

2017-06-28 21:13:19

#### [LeetCode-204] Count Primes（0~n 有多少个质数—4种方法求解）

2015-10-23 15:18:31

## 不良信息举报

leetcode-204 Count Primes