leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

0204.cpp (322B)


      1 class Solution {
      2   public:
      3     int countPrimes(int n) {
      4         vector<bool> sieve(n);
      5         int res = 0;
      6         for (long i = 2; i < n; i++) {
      7             if (sieve[i]) continue;
      8             for (long j = i * i; j < n; j += i)
      9                 sieve[j] = true;
     10             res++;
     11         }
     12         return res;
     13     }
     14 };