code is given below pls help
Tle in last test case help
When the number of test cases is less, your code is working fine.
The problem with your code is that for large number of test cases you are running the prime sieve again and again for each test case which is making the process inefficient and exceeding the time limit. So call the prime sieve function outside the loop for the test case.
Follow this approach:(I have commented out the steps)
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.