题目:
题解:
class Solution:def longestCommonPrefix(self, strs: List[str]) -> str:def isCommonPrefix(length):str0, count = strs[0][:length], len(strs)return all(strs[i][:length] == str0 for i in range(1, count))if not strs:return ""minLength = min(len(s) for s in strs)low, high = 0, minLengthwhile low < high:mid = (high - low + 1) // 2 + lowif isCommonPrefix(mid):low = midelse:high = mid - 1return strs[0][:low]