Problems > Longest Common Prefix > Editorial

Longest Common Prefix — Solution & Editorial

Back to the Problem

Start with the first word as the candidate and shrink it against each next word.

Complexity: O(total input size)