This commit is contained in:
Gyubin Han
2025-02-19 14:09:55 +09:00
parent e3c6c8b32a
commit dede0dca01
36 changed files with 555 additions and 0 deletions

14
leetcode/14.py Normal file
View File

@@ -0,0 +1,14 @@
class Solution:
def longestCommonPrefix(self, strs: List[str]) -> str:
last=strs[0]
for i in range(1,len(strs)):
if len(last)<1:
break
for j in range(min(len(last),len(strs[i]))):
if not last[j]==strs[i][j]:
last=last[0:j]
break
if len(last)>len(strs[i]):
last=last[0:len(strs[i])]
return last