Why i am facing TLE in 1 test case even used cummulative sum approach

Hello @sid.rajput23 you are getting TLE because you are forming the prime sieve for every test case:
so in large test case:
you will get the error.
Here for your reference i am attaching the code:


if you have any doubt you can ask here:
Happy Learning!!

1 Like

you have not created any cummulative sum array , i think you have created a very large sieve once and you have searched over the entire array from a to b

@sid.rajput23 yes right this is onlt the correct approach for this:
otherwise if you will form the sieve for every time then it will definitely give error.
if you have any doubt you can ask here:
Happy Learning!!

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.