[LeetCode]598. Range Addition II
题目描述
思路
筛选重复加最多的区域
即ops数组中的最小值,得到行列相乘即可
代码
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
class Solution {
public:
int maxCount(int m, int n, vector<vector<int>>& ops) {
int resRow = m, resCol = n;
for (vector<int> vec : ops) {
resRow = min(resRow, vec[0]);
resCol = min(resCol, vec[1]);
}
return resRow * resCol;
}
};
int main() {
Solution s;
vector<vector<int>> ops = { {3, 3}, {2, 2} };
cout << s.maxCount(3, 3, ops) << endl;
system("pause");
return 0;
}
890



被折叠的 条评论
为什么被折叠?



