Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution:
- def longestCommonPrefix(self, strs: List[str]) -> str:
- ans = ""
- for j in range(300):
- flag = True
- for i in range(len(strs)):
- if j >= len(strs[i]):
- flag = False
- break
- if strs[i][j] != strs[0][j]:
- flag = False
- break
- if flag:
- ans = ans + strs[0][j]
- else:
- break
- return ans
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement