i have solved the question using the sieve method but the complexity is O(n^3) in this question.I am not able to figure how to remove this time limit error
Time limit in prateek loves candy
Hello @anishmittal,
Before while loop:
You can use the prime sieve approach and store all the prime numbers in a vector or array up to 10^9.
Inside while loop:
You can use this array to print the nth prime in O(1) time complexity pass using n-1 as index.
Hope, this would help.
Give a like, if you are satisfied.