forked from liuyubobobo/Play-Leetcode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
36 lines (28 loc) · 781 Bytes
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/// Source : https://leetcode.com/problems/range-addition-ii/description/
/// Author : liuyubobobo
/// Time : 2017-10-28
#include <iostream>
#include <vector>
using namespace std;
/// Time Complexity: O(len(ops))
/// Space Complexity: O(1)
class Solution {
public:
int maxCount(int m, int n, vector<vector<int>>& ops) {
int x = m, y = n;
for(vector<int> op: ops){
x = min(x, op[0]);
y = min(y, op[1]);
}
return x * y;
}
};
int main() {
int m = 3, n = 3;
int ops[2][2] = {{2, 2}, {3, 3}};
vector<vector<int>> vec;
for(int i = 0 ; i < 2 ; i ++)
vec.push_back(vector<int>(ops[i], ops[i] + sizeof(ops[i])/sizeof(int)));
cout << Solution().maxCount(m, n, vec) << endl;
return 0;
}