求字符串最大前缀

class Solution:

    def longestCommonPrefix(self, strs: List[str]) -> str:

        tem = strs[0]

        liebiaolen = len(strs)

        strlen = len(tem)

        tempstr = []

        for i in range(0,strlen):

            for j in range(1,liebiaolen):

                temp = strs[j]

                if ((len(temp)>i)&(tem[i]==temp[i])):

                    tempstr.append(tem[i])

                else:

                    break


        print(''.join(temstr))

你可能感兴趣的:(求字符串最大前缀)