TLE for case 1 rest r okay(code is given below)

you need to use seive .refer to this code here

I m a beginner right now, not even started functions yet, can it be a little simpler than that :sweat_smile:

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.

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. :slight_smile:

try to understand this code here by debugging through it

thank you for ur assistance

please mark your doubt as solved and rate as well :slight_smile: