力扣初级算法——最长公共前缀
作者:互联网
题目描述:
答案:
class Solution:
def longestCommonPrefix(self, strs: List[str]) -> str:
a= len(strs)
if not str:
return ""
b = strs[0]
c=len(b)
for i in range(c):
for j in range(1,a):
if i ==len(strs[j]) or b[i] != strs[j][i]:
return b[0:i]
return b
c此处:if a == 0 与if not str 相同
标签:return,前缀,strs,range,len,力扣,算法,str,longestCommonPrefix 来源: https://blog.csdn.net/weixin_51512722/article/details/120383354