← Discussions on Length of Last Word
A arjundas
28 Jul 2026, 06:04

Asked in my Google 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.

2 replies

pbanerjee 4 months ago

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

shegde 4 months ago

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

Sign in to reply.