fork download
  1. class Solution:
  2. def longestCommonPrefix(self, strs: list[str]) -> str:
  3. result =""
  4. for i in range(len(strs[0])):
  5. for s in strs:
  6. if i==len(s) or s[i] != strs[0][i]:
  7.  
  8. return result
  9. result +=strs[0][i]
  10. return result
  11.  
  12. # your code goes here
Success #stdin #stdout 0.12s 14164KB
stdin
strs = ["flower","flow","flight"]
stdout
Standard output is empty