Related to a question in last codeforces contest

I asked the same thing on codeforces but that comment may not get attention so i thought let post it here too so what happened is i submiitted a question during contest it was AC but after contest ended and i just checked and its showing TLE(also i dont know why TLE as time limit was 2 sec) and i again submitted the same code now and now it showing AC(the same code) but due to that TLE my ranking is messed up :pensive: what should i do and can anyone help me in finding the problem what is wrong (why TLE ) after reading other codes i know that i could have done that but still time limit was 2 sec. so why why its showing TLE
here are both the codes
Accepted submission
TLE submission
Thanks

The operation: s=s+'9' takes almost O(n^2) in worst case . During system check, maybe due to server load it TLEd. Try using s+='9'. Just notice the significant difference in memory. It will take just 30-40 ms compared to this 1045 ms.

2 Likes

yeah nice i forgot that s will be copied everytime XD Thanks

Or u can write this too .

s.pushback('9')