Description:
Count the number of prime numbers less than a non-negative number, n.
public class Solution { public int countPrimes(int n) { boolean isPrime[] = new boolean[n]; int count = 0; for(int i = 2; i < n ; i++){ if(isnotPrime[i] == false){ count ++; for(int j = 2; j * i < n; j++){ isnotPrime[i*j] = true; } } } return count; } }