Java O(n) solutions getting Time Limit Exceeded?

Revision en1, by martin_1, 2021-08-17 22:44:23

I have been submitting a few java submissions lately and all of them have been getting Time Limit Exceeded even though I think I am either doing the same solution as the editorial or my solution runs in O(n).

Here are two examples: https://codeforces.com/contest/1334/submission/126210107

https://codeforces.com/contest/1334/submission/126127281

Why is this happening? It's quite discouraging to think I solved a problem with an OK solution then TLE so many times...

Thanks!

Tags time limit, #greedy, #java, #implementaion, linear time, o(n), #time complexity

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English martin_1 2021-08-17 22:44:23 535 Initial revision (published)