Advertisement
FreyasSpirit

Untitled

Feb 17th, 2020
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. class Solution(object):
  2. def longestCommonPrefix(self, strs):
  3. """
  4. :type strs: List[str]
  5. :rtype: str
  6. """
  7. result = ""
  8. if len(strs) == 0:
  9. return ""
  10. for i in range(len(strs[0])):
  11. char = strs[0][i]
  12. for str in strs:
  13. if len(str) < i+1 or char != str[i]:
  14. return result
  15.  
  16. result = result + char
  17.  
  18. return result
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement