204. Count Primes
Easy
Question
Count the number of prime numbers less than a non-negative number, n.
Example:
Method
Sieve of Eratosthenes (https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes)
Complexity
Time complexity: O(n * sqrt(n))
Space complexity: O(1)
Code
Note: The question requires less than n.
Last updated
Was this helpful?