Skip to content

Commit 69284d5

Browse files
authored
Update solution 014 [Python2]-20ms
1 parent 8e4c094 commit 69284d5

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Solution2.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class Solution(object):
2+
def longestCommonPrefix(self, strs):
3+
if not strs:
4+
return ""
5+
for i,group in enumerate(zip(*strs)):#把字符串变成一个字母一个字母的格式
6+
if len(set(group))>1: #集合里多于一个字符
7+
return strs[0][:i] #输出0到目前编号位的字符
8+
else:
9+
return min(strs) #其他情况
10+

0 commit comments

Comments
 (0)