Pregunta de entrevista de Capital One

Leetcode Count primes, looking for optimal solution