Problem
- Leetcode 14. Longest Common Prefix
- Level: Easy
- Link
My Code
class Solution:
def longestCommonPrefix(self, strs: List[str]) -> str:
strs, temp = sorted(strs),""
for i in range(len(strs[0])):
if strs[0][i] == strs[-1][i]: temp += strs[0][i]
else: break
return temp
'개발공부 > algorithm' 카테고리의 다른 글
[Leetcode][python] 11: Container with most water - Two pointer (0) | 2021.07.15 |
---|---|
[Leetcode][python] 1528. Shuffle String (0) | 2021.07.04 |
[Leetcode][python] 374. Guess Number Higher or Lower - Binary Search (0) | 2021.07.04 |
[leetcode][python] 278. First Bad Version - Binary Search (0) | 2021.07.04 |
[Leetcode][python] 58: Length of Last Word (0) | 2021.06.24 |