204. Count Primes

Description:

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

一刷
题解:这题不用brute-force来求解。
i从2到n遍历, j从2到i遍历。ijj] = true

public class Solution {
    public int countPrimes(int n) {
        boolean[] notPrime = new boolean[n];
        int count = 0;
        for(int i=2; i

你可能感兴趣的:(204. Count Primes)