Getting TLE!!

HI , I am keep on getting TLE.

I am using BufferedReader for Input reading ,and I do not use any nested loops in my program, even when iterating from 0 to 10^4 once(which generates the correct ans), the system says TLE.

Can anyone please give me some tips on how to avoid TLE, and any common mistakes that a begginer like me might overlook.

Thanks
(using Java)

Then maybe further optimization is required. Sometimes even O(n) solution gives TLE.

1 Like

@mightymosquito : May be you are not incrementing the loop counter . So the loop goes forever . A loop of 10^4 with very basic steps in it cannot give TLE . If it is not related to the current ongoing contest you can give a link to your code and I will see .

Unfortunately it is related to the June cook off…so cant say anything,but no the loop was not infinite though.