update project structure
This commit is contained in:
19
leetcode_py/14.py
Normal file
19
leetcode_py/14.py
Normal file
@@ -0,0 +1,19 @@
|
||||
# find the longest common prefix
|
||||
# 1 <= strs.length <= 200
|
||||
# 0 <=strs[i].length <= 200
|
||||
# only lowercase
|
||||
class Solution:
|
||||
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]:
|
||||
return return_string
|
||||
return_string += strs[0][i]
|
||||
i += 1
|
||||
except:
|
||||
return return_string
|
||||
|
||||
return return_string
|
||||
Reference in New Issue
Block a user