def longestCommonPrefix(strs):
"""
:type strs: List[str]
:rtype: str
"""
if not strs:
return ''
s1 = min(strs)
s2 = max(strs)
for i, c in enumerate(s1):
if c != s2[i]:
return s1[:i]
return s1
ls1 = input().split()
result = longestCommonPrefix(ls1)
if result == '':
print('NOT FOUND')
else:
print(result)
共有前缀(列表集合)
最新推荐文章于 2023-10-31 20:34:42 发布