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)


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