DevHireLab
TutorialsBootcamp
Problems
Code SimulatorAI InterviewSoonContact
DevHireLab
TutorialsBootcamp
Problems
Code SimulatorAI InterviewSoonContact
Back to Arena
medium
Math

Count Primes

**Problem Statement:** Given the required input arguments, write an efficient algorithm to solve the **Count Primes** problem. Implement the required logic as specified by standard definitions for this classic algorithmic challenge. **Hint / Expected Approach:** Sieve of Eratosthenes **Edge Cases to Consider:** - (1) n ≤ 2 (zero primes) - (2) n = 3 - (3) Large n memory concern

Examples

Example 1
Input: 10
Output: 4
Explanation: 2,3,5,7
Example 2
Input: 0
Output: 0
Example 3
Input: 1
Output: 0

Constraints

  • ▪Input arguments are within valid ranges
  • ▪Optimize for execution speed
  • ▪Handle null/empty inputs gracefully

Watch Out For Edge Cases

  • ▪n ≤ 2 (zero primes)
  • ▪n = 3
  • ▪Large n memory concern
Frequently Asked At
AmazonGoogleMicrosoftAdobeTCS