题解 | #最长公共前缀#
最长公共前缀
https://www.nowcoder.com/practice/28eb3175488f4434a4a6207f6f484f47
def longestCommonPrefix(self , strs: List[str]) -> str: # write code here count = len(strs) if count==0: return "" else: for i in range(len(strs[0])): temp = strs[0][i] for j in range(1,count): # len(strs[j])==i 退出 # 确定此时strs[j][i]是存在的 if len(strs[j])==i or strs[j][i]!=temp: return strs[0][0:i] return strs[0]