Prateek Loves Candy


there is some timelimit issue,how to resolve it

@akb.tech17 do one task just increase the range of max and the time limit will resolve.

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.

getting tle https://ide.codingblocks.com/s/190271

@akb.tech17 what you are doing in your code is not optimal you are calling prime function for every test case and running a while loop too of size n this will give you TLE for sure.
what you should do is store all the prime numbers upto your max size in a vector and just print vec[n-1] for every test case as it will be your nth prime number.

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.