Count Primes LeetCode solution in Java

1
class Solution {
2
public int countPrimes(int n) {
3
boolean check[] = new boolean[n];
4
int count = 0;
5
for (int i = 2; i < n; i++) {
6
if (check[i] == false) {
7
count++;
8
for (int j = i; j < n; j += i) {
9
check[j] = true;
10
}
11
}
12
}
13
return count;
14
}
15
}

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0