Leetcode14-最小前缀

class Solution(object):
    def longestCommonPrefix(self, strs):
        """
        :type strs: List[str]
        :rtype: str
        """
        if len(strs)== 0: return ''
        temp = strs[0]
        for str in strs:
            while str.find(temp) != 0:
                temp = temp[:-1]
                

        return temp

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_35180757/article/details/106794012