My code is failing for one test case, it shows time limit exceeds. How can we optimize it further?
Find Nth prime number
the most optimal approach to solve this particular problem is to first generate all primes less than 10^6 using sieve. Then, store all the primes in a separate list, and for each query with input x, simply print the xth prime from the list.
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.