← Discussions on Length of Last Word
C chegde
13 Jul 2026, 16:27

Asked in my CRED OA last week.

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

1 reply

harshchatterjee 3 months ago

Great explanation, the edge case with an empty input tripped me up too.

Sign in to reply.