https://online.codingblocks.com/app/player/163501/content/168353/4702/code-challenge
This code is giving error TLE for one test case but is passing other test cases. Please help.
Prateek Loves Candy TLE error
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. 
try to understand this code here by debugging through it
Hi Abha,
While running your code the following error is coming, any idea how to rectify it.
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
my bad, just mention the type in arraylist in line 46 as
ArrayList<Integer> ans = new ArrayList<>();
Thank you so much Abha, the code is working fine now.
np
please mark your doubt as resolved