计算缝隙个数的和,缝隙就是前面的和 class Solution: def leastBricks(self, wall: List[List[int]]) -> int: dic = {-1:0} for num in wall: total = 0 for i in range(len(num)-1): total = total + num[i] if total in dic: dic[total] = dic[total] + 1 else: dic[total] = 1 return len(wall) - max(dic.values())