Unable to clear test case 4 as my time limit is exceeding!PLEASE HELP


—link to my code

@Yuvraj_Luhach,
Instead of calculating for every test case. First take input of all test cases and find the maximum test case value. Now find till that n only. It will greatly reduce the time complexity because repetitive calls will be avoided

Do you mean to say that I should find primes and mark them as true upto 5 --as in the test case .
But it is not working as we want to find the 5th prime number and not check whether 5 is a prime no or not .

@Yuvraj_Luhach,
Test case:
3
5
12
8
Now find the max value of this, which is 12. Now store all prime numbers till 12 in an arraylist, compute the list using the sieve of eratosthenes as you have done. Finally just print the correct element from the arraylist.
Code for help: https://ide.codingblocks.com/s/179293

Thanks for your help

hey @Yuvraj_Luhach As I can see you have reopened the doubt.So tell me the doubt.

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.