Skip to content

Commit c80f266

Browse files
authored
Create longestCommonPrefix.py
1 parent eeb0f20 commit c80f266

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import pysnooper
2+
3+
@pysnooper.snoop()
4+
def longestCommonPrefix(strs):
5+
ans = ''
6+
for i in zip(*strs):
7+
print(i)
8+
if len(set(i)) == 1:
9+
ans += i[0]
10+
else
11+
break
12+
return ans
13+
14+
if __name__ == 'main':
15+
longestCommonPrefix(["flower","flow","flight"])

0 commit comments

Comments
 (0)