0%

253. Meeting Rooms II

O(nlogn) time O(n) space

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
class Solution {
public:
int minMeetingRooms(vector<vector<int>>& intervals) {
map<int, int> m;
for (const auto &i : intervals) {
++m[i[0]];
--m[i[1]];
}
int res = 0, cnt = 0;
for (auto [_, c] : m) {
res = max(res, cnt += c);
}
return res;
}
};