Practice Count Primes
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Given an integer n, return the number of prime numbers that are strictly less than n.
Source: Count Primes on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
n = 10
Output
4
# Example 2
Input
n = 0
Output
0
# Example 3
Input
n = 1
Output
0
Constraints
0 <= n <= 5 * 10^6
Related LeetCode Problems
Practice more problems similar to Count Primes.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.