【leetcode】598. Range Addition II

时间:2023-03-08 17:07:31

  You are given an m x n matrix M initialized with all 0's and an array of operations ops, where ops[i] = [ai, bi] means M[x][y] should be incremented by one for all 0 <= x < ai and 0 <= y < bi.

Count and return the number of maximum integers in the matrix after performing all the operations.
  
class Solution {
public:
int maxCount(int m, int n, vector<vector<int>>& ops) { //取所有操作的交集就是最大int number的个数 冷静思考就没问题 啊哈哈哈
if(ops.size()==0) return m*n;
int limit_m=m,limit_n=n;
for(auto aa:ops)
{
limit_m=min(limit_m,aa[0]);
limit_n=min(limit_n,aa[1]);
}
return limit_m*limit_n;
}
};