i am getting TLE. how do i optimize my solution
Deepak and primes
@sh3rlock
hello Sambhav,
I think u are using brute force approach ie going to each number and checking whether it is prime or not.
to optimise ur solution use Sieve of Eratosthenes .using this technique u can can answer whether a number is prime or not in O(1) time.
if u r not familiar with this technique then check this video tutorial by prateek bhaiya
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.