Skip to content

Commit 42278a9

Browse files
authored
Create 2406. Divide Intervals Into Minimum Number of Groups (#611)
2 parents 4f2d700 + e4fce59 commit 42278a9

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class Solution {
2+
public:
3+
int minGroups(vector<vector<int>>& intervals) {
4+
vector<int> v(1000002,0);
5+
int n = 0;
6+
for(auto X: intervals){
7+
n = max(n, X[1]);
8+
v[X[0]]++;
9+
v[X[1]+1]--;
10+
}
11+
int pfx= 0 , ans = 0;
12+
for(int i = 0 ;i <= n; i++){
13+
pfx+=v[i];
14+
ans = max(ans, pfx);
15+
}
16+
return ans;
17+
}
18+
};

0 commit comments

Comments
 (0)