Capital One Interview Question

Leetcode Count primes, looking for optimal solution