Sieve

3 articles

dsa18 min read

Count Primes — Sieve of Eratosthenes O(n log log n) [Amazon Easy]

Count primes below n sounds trivial — until your naive solution times out on n=5,000,000. Master the Sieve of Eratosthenes, one of the most elegant algorithms in all of computer science, and learn the exact intuition that separates candidates who pass Amazon and Google screens from those who do not.

Read →