leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

2406.cpp (541B)


0 class Solution {
1 public:
2 int minGroups(vector<vector<int>> &intervals) const {
3 static int start[1000001], end[1000001];
4 int res = 1;
6 memset(end, 0x00, sizeof(end));
7 memset(start, 0x00, sizeof(start));
9 for (const auto &inter : intervals) {
10 start[inter[0]]++;
11 end[inter[1]]++;
12 }
14 for (int i = 1, acc = 0; i <= 1000000; i++) {
15 acc += start[i];
16 res = max(res, acc);
17 acc -= end[i];
18 }
20 return res;
21 }
22 };