← Discussions on Length of Last Word
Z zoyamuk6
14 Oct 2026, 16:58

Simple approach explained for beginners.

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

aryan.n 1 month, 2 weeks ago

This should be marked as the editorial approach honestly.

yamini.s 1 month, 2 weeks ago

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

srinivasiye5 1 month, 2 weeks ago

Watch out for integer overflow in Java on the large test.

Sign in to reply.