Search⌘ K
AI Features

Solution: Count Primes

Explore how to count prime numbers strictly less than a given integer n by applying the Sieve of Eratosthenes algorithm. Understand key steps including initialization, marking multiples of primes, and counting remaining candidates. This lesson helps you implement an optimized solution with O(n log log n) time complexity, preparing you for mathematical and number theory coding challenges.

Statement

Given an integer n, return the count of prime numbers that are strictly less than n.

Constraints:

  • 00 \leq n 5×106\leq 5 \times 10^6 ...