i am not able to submit challenge prateek loves candy
Not able to submit the code
so how can i help u?
should i explain the approach?
when i click on the submit button then it says submitting and after few seconds nothing happens and then the button again changes to submit.
this is becoz ur code is showing tle
effficient approach:
find the maximum number from all of the testcases.
then, Use SOE(Sieve of Eratosthenes) to find the prime number upto that number and store that an the array.
or simply store the no. in the array where index value shows the no. of prime no. are there
and then for each test case just return the value for the input
and pls see the Sieve of Eratosthenes algo to find the prime no
hope this will help u
pls rate my work
how to find the maximum number from all of the testcases
store the input in an array
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.
i am still not able to get what you are trying to suggest
hi @jatin111
Main logic behind the question is that you need to find the nth prime number starting from 2. Any one can implement this logic “Not a big Deal” for anyone, but wait a min there’s more to it.
Many of you are getting time limit exceed right ? Even if you are using SOE (Sieve of Eratosthenes) for finding the prime numbers.
Have u see the constraint on number of test cases, It’s quite large because for every test case you are going to find the prime numbers upto that number and at last return the last prime number found, this will cause the TLE for big test cases.
So, to overcome this problem, let’s just store your test cases in an array.
Then find the maximum number from all of the testcases.
then, Use SOE(Sieve of Eratosthenes) to find the prime number upto that number and store that an the array.
After storing, simply loop over every test case that was stored previously in an array.
Print the value of n from the array storing primes.
That’s how we need not to find the prime number for every test case. 
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.