Back to exercises

Longest Common Prefix

Shrink the candidate prefix until every string starts with it. If it becomes empty, there is no shared prefix.

Coding Exercises Easy O(n * m)

Longest Common Prefix

Shrink the candidate prefix until every string starts with it. If it becomes empty, there is no shared prefix.

Return the longest common prefix shared by all strings in a list.