题目:14. Longest Common Prefix
链接:https://leetcode.com/problems/longest-common-prefix/description/
找到给定的若干个字符串的最长公共前缀。
python:
class Solution:
def longestCommonPrefix(self, strs):
"""
:type strs: List[str]
:rtype: str
"""
res=""
for item in map(set,(zip(*strs))):
if len(item)==1:
res+=item.pop()
else:
break
return res