PRIME VISIT PROBLEM

CODE: https://ide.codingblocks.com/s/647091

Why this code giving TLE in 1 test case. All other test cases passes sucessfully.

hi @rahul_bansal
its giving TLE because u are computing prime for every test case, but what u can do is first compute prime numbers till 10^6, and then perform on test cases…
refer this -->


rest ur logic is correct…

1 Like

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.