# https://leetcode.cn/problems/longest-common-prefix/# 编写一个函数来查找字符串数组中的最长公共前缀。# 如果不存在公共前缀,返回空字符串 ""。class Solution:def longestCommonPrefix(self, strs) :if not strs:return ""prefix,count=strs[0],len(strs)for i in range(1,count):prefix=self.lcp(prefix,strs[i])if not prefix:breakreturn prefixdef lcp(self,s1, s2):i = 0while i < len(s1) and i < len(s2) and s1[i] == s2[i]:i += 1return s1[:i]
