← 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 2 days, 12 hours ago

This should be marked as the editorial approach honestly.

yamini.s 2 days, 1 hour ago

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

srinivasiye5 1 hour, 10 minutes ago

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

Sign in to reply.