update 14
This commit is contained in:
parent
a95031128d
commit
b916e0f709
@ -3,19 +3,18 @@
|
||||
# 0 <=strs[i].length <= 200
|
||||
# only lowercase
|
||||
class Solution:
|
||||
def longestCommonPrefix(self,strs: list[str]) -> str:
|
||||
returnString = ""
|
||||
index = 0
|
||||
while i < len(str[0]):
|
||||
try:
|
||||
for string in strs:
|
||||
if string[i] == strs[0][i]:
|
||||
i += 1
|
||||
returnString += string[i]
|
||||
else:
|
||||
break
|
||||
except:
|
||||
break
|
||||
def longestCommonPrefix(self, strs: list[str]) -> str:
|
||||
return_string = ""
|
||||
i = 0
|
||||
while i < len(strs[0]):
|
||||
try:
|
||||
for string in strs:
|
||||
if string[i] != strs[0][i]:
|
||||
break
|
||||
|
||||
return returnString
|
||||
i += 1
|
||||
return_string += strs[0][i]
|
||||
except:
|
||||
break
|
||||
|
||||
return return_string
|
||||
|
Loading…
x
Reference in New Issue
Block a user