14_Longest Common Prefix
Last updated
Last updated
[easy] [string]
Write a function to find the longest common prefix string amongst an array of strings. All given inputs are in lowercase lettersa-z
. If there is no common prefix, return an empty string""
.
Example 1:
Example 2:
Idea:
scan over each column, check if the characters are the same.
Time Complexity: m is the number of strings in the input, n is the min length of the strings.
Space Complexity: