easy python


  • 0
    S
    class Solution(object):
        def longestCommonPrefix(self, strs):
            """
            :type strs: List[str]
            :rtype: str
            """
            try:
                i = 0
                while len(set([s[i] for s in strs])) == 1:
                    i += 1
            except:
                pass
            
            return strs[0][:i] if strs else ''
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.