KPRIME Problem - CodeChef This is the question i was attempting.Here is my code getting TLE
CodeChef: Practical coding for everyone .This is another solution by one @gargmehul10 CodeChef: Practical coding for everyone getting AC with a time of 0.59 s. Even though my code uses lesser loops and we both followed the same concept, mine gets a TLE. Can someone please explain?
Reason for TLE:
The code by @gargmehul10 executes the sieve only once inside main()
for all the t
test cases.
Your code executes the sieve t
times for t
test cases.
You are calling solve()
which contains the sieve for all the t
test cases.
Consider putting the sieve part in one function and call it just once before answering the test cases.
I hope this cleared your doubt.
All the best!
1 Like
Thank you very much! Doubt cleared.