Skip to content

Commit 117bd23

Browse files
committed
committed from zkp
1 parent dd720cf commit 117bd23

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

LeetCode/longestCommonPrefix.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution:
2+
def longestCommonPrefix(self, strs):
3+
"""
4+
:type strs: List[str]
5+
:rtype: str
6+
"""
7+
if len(strs) == 0:
8+
return ''
9+
s = strs[0]
10+
for i in strs[1:]:
11+
while s != i[:len(s)]:
12+
s = s[:-1]
13+
return s

0 commit comments

Comments
 (0)