[LeetCode] 14. Longest Common Prefix
Python
class Solution:
def longestCommonPrefix(self, strs: List[str]) -> str:
if not strs:
return ""
temp = min(strs, key=len)
for i, v in enumerate(temp):
for other in strs:
if other[i] != v:
return temp[:i]
return temp
댓글남기기