Skip to content

Commit d5a1799

Browse files
committed
Time: 32 ms (81.40%), Space: 14.3 MB (81.81%) - LeetHub
1 parent 011e7ac commit d5a1799

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class Solution:
2+
def longestCommonPrefix(self, strs: List[str]) -> str:
3+
prefix = ''
4+
for x in zip(*[list(x) for x in strs]):
5+
if len(set(x)) == 1:
6+
prefix += x[0]
7+
else:
8+
break
9+
return prefix

0 commit comments

Comments
 (0)