1
class Solution {
2
public:
3
bool isRectangleCover(vector<vector<int>> &rectangles) {
4
unordered_map<long long, int> mark;
5
const long long N = 1000000;
6
for (vector<int> &x : rectangles) {
7
int x1 = x[0];
8
int y1 = x[1];
9
int x2 = x[2];
10
int y2 = x[3];
11
mark[x1 * N + y1]++;
12
mark[x1 * N + y2]--;
13
mark[x2 * N + y1]--;
14
mark[x2 * N + y2]++;
15
}
16
int n_mark = 0;
17
for (auto ptr = mark.begin(); ptr != mark.end(); ptr++)
18
if (ptr->second != 0) {
19
if (abs(ptr->second) != 1) return false;
20
n_mark++;
21
}
22
return n_mark == 4;
23
}
24
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0