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