解题思路
本题的思路,就是查找矩阵M在operation下重叠的部分.
代码
class Solution(object): def maxCount(self, m, n, ops): """ :type m: int :type n: int :type ops: List[List[int]] :rtype: int """ list1,list2 = [m],[n] for num in ops: list1.append(num[0]) list2.append(num[1]) list1_min = min(list1) list2_min = min(list2) return list1_min * list2_min
也可
class Solution(object): def maxCount(self, m, n, ops): """ :type m: int :type n: int :type ops: List[List[int]] :rtype: int """ list1_min,list2_min = m,n for num in ops: list1_min = min(list1_min,num[0]) list2_min = min(list2_min,num[1]) return list1_min * list2_min a = Solution() a.maxCount(3,3,[[2,2],[3,3]])