I am not able to pass 1 out of 3 test cases in the question: Prime Visits

Not able to pass the Test Case 2.
Kindly help. Here is the link:

Precompute your sieve array before taking any inputs for the test cases

You mean like this? https://ide.codingblocks.com/s/265236

No I mean fill your sieve array before upto a certain size as per the contraints given

This way you will avoid doing the same computations again and again, for the test cases

Got it!..Hogaya! :pleading_face: Thank you SO MUCH!!!

Welcome
Please mark your doubt as resolved now