思路:每次操作的都是左上角区域0<=i<a以及0<=j<b的元素使M[i][j]的值增加1,所以找出ops中操作重叠的部分计算大小即可。
代码:
class Solution {
public int maxCount(int m, int n, int[][] ops) {
for(int[] op:ops){
m=Math.min(m,op[0]);
n=Math.min(n,op[1]);
}
return m*n;
}
}