package leetcode;

/**
 * https://leetcode.com/problems/count-primes/
 */
public class Problem204 {
    public int countPrimes(int n) {
        // TODO:
        return 0;
    }
    
    public static void main(String[] args) {
        Problem204 prob = new Problem204();
        System.out.println(prob.countPrimes(10));
    }
}

@@ -12,16 +12,65 @@
 tcode;%0A%0A
+import java.util.HashSet;%0Aimport java.util.Set;%0A%0A
 /**%0A * h
@@ -193,30 +193,457 @@
  // 
-TODO:%0A        return 0
+https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes%0A        int prime = 0;%0A        Set%3CInteger%3E set = new HashSet%3C%3E();%0A        for (int i = 2; i %3C= n; i++) %7B%0A            set.add(i);%0A        %7D%0A        for (int i = 2; i %3C= n; i++) %7B%0A            if (!set.contains(i)) %7B%0A                continue;%0A            %7D%0A            for (int j = i; j %3C= n; j += i) %7B%0A                set.remove(j);%0A            %7D%0A            prime++;%0A        %7D%0A        return prime
 ;%0A  
@@ -788,10 +788,64 @@
 mes(
-10
+20));%0A        System.out.println(prob.countPrimes(999983
 ));%0A

Update problem 204 (still too slow)