is the code that i have written but it is showing TLE even though i have made the sieve array outside the while loop.
Showing Time Limit Exceeded
@Siddharth6780
hello siddharth ,
ur current time complexity is roghly O( t*n + nloglog(n)) so to improve it. first store all prime numbers in vector or array (say prime)and then for each test case print prime[n-1] (n-1 because 0 based indexing).
this will improve time complexity to O(t+ nloglog(n))
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.