Shows TLE , even though i used Sieve and same code worked for Deepak and Primes with No TLE error
Prateek loves candy , TLE error
it still shows TLE even after long long int.
its the same link as above.
hey @S19LPPP0159, you are getting TLE becasue for every testcase you are running for loop with high n value. You should maintain a container that will store the all prime number like array where index 1 has 2, index 2 has 3 and so one.
I have made changes to your code. You can check them here.https://ide.codingblocks.com/s/98673.
You have modified it to a different question, In Prateek loves candy, we were supposed to print nth Prime number,
suppose nth=5
then we are supposed to print 11, which is 5th prime number starting from 2.
Hey @Gaurav13998, modified to same question only.You can search that container and get nth prime number. Try to run the code that I have sent you.
hey @S19LPPP0159, okay make it cout<<arr[nth] instead of arr[nth-1], it work fine then. I forgot to change this.
hey @S19LPPP0159 , if your query is resolved. Please mark this doubt as resolved and rate me on the basis of your experience.
rating option will appear when to mark this doubt as resolved