← Discussions on Reverse String
V vikramban9 OFFICIAL
03 Jun 2026, 15:16

Why does my solution TLE on the last test case?

Work with character counts or indices rather than building new strings in the loop; string concatenation inside loops is what usually causes TLE here.

3 replies

pbanerjee 4 months, 1 week ago

Same idea, but I used a deque. Works fine.

manish.k 4 months, 1 week ago

This should be marked as the editorial approach honestly.

ritika_24 4 months, 1 week ago

You can avoid the extra array and do it in O(1) space.

Sign in to reply.