Unable to compute test case 4 bec of TLE


Please suggest optimization so that 4 th test case can be evaluated

use sieve of eratosthenes to store the first 10^6 primes and then print the nth prime.

What is that . I dont have any idea about it

Sieve of Eratosthenes is a method to generate primes for a particular range in O(n log log n) time complexity. It is beneficial for questions where we need the primes from a certain range and calculating primes at that very moment is time costly. For more details implementation: give a quick look at the GFG article. In case you don’t understand, please feel free to ask.

Can you please tell me how to use that in the code.

Did you have a look at the tutorial from GFG ?

1 Like

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.