Advertisement
smj007

Untitled

Sep 16th, 2023
804
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.30 KB | None | 0 0
  1. class Solution:
  2.     def longestCommonPrefix(self, strs: List[str]) -> str:
  3.    
  4.         res = ""
  5.         for i in range(len(strs[0])):
  6.             for s in strs:
  7.                 if i==len(s) or s[i]!= strs[0][i]:
  8.                     return res
  9.             res += strs[0][i]
  10.  
  11.         return res
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement