please tell the error
this is the code :
Prateek Loves Candy
Its giving Time limit exceeded
Hi @Bansaljatin05
Time limit error is because for every test case you have to iterate over the p array again and again. Instead while in primeSieve function you just save the value of number of primes n corresponding to value i in an array. Then in main you can directly access the count till which n prime numbers are present just by array[n] which will just take O(1) time.
1 Like