The Longest Word — Solution & Editorial
Track the best length while scanning left to right, replacing only on strictly longer words.
Complexity: O(length)
Track the best length while scanning left to right, replacing only on strictly longer words.
Complexity: O(length)