update 14

This commit is contained in:
sangge-rockpi 2024-01-20 12:51:08 +08:00
parent a95031128d
commit b916e0f709

View File

@ -4,18 +4,17 @@
# only lowercase
class Solution:
def longestCommonPrefix(self, strs: list[str]) -> str:
returnString = ""
index = 0
while i < len(str[0]):
return_string = ""
i = 0
while i < len(strs[0]):
try:
for string in strs:
if string[i] == strs[0][i]:
i += 1
returnString += string[i]
else:
if string[i] != strs[0][i]:
break
i += 1
return_string += strs[0][i]
except:
break
return returnString
return return_string