Problems > The Longest Word > Editorial

The Longest Word — Solution & Editorial

Back to the Problem

Track the best length while scanning left to right, replacing only on strictly longer words.

Complexity: O(length)