Skip to content

Commit

Permalink
Create 2406. Divide Intervals Into Minimum Number of Groups (#611)
Browse files Browse the repository at this point in the history
  • Loading branch information
Chayandas07 authored Oct 12, 2024
2 parents 4f2d700 + e4fce59 commit 42278a9
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions 2406. Divide Intervals Into Minimum Number of Groups
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class Solution {
public:
int minGroups(vector<vector<int>>& intervals) {
vector<int> v(1000002,0);
int n = 0;
for(auto X: intervals){
n = max(n, X[1]);
v[X[0]]++;
v[X[1]+1]--;
}
int pfx= 0 , ans = 0;
for(int i = 0 ;i <= n; i++){
pfx+=v[i];
ans = max(ans, pfx);
}
return ans;
}
};

0 comments on commit 42278a9

Please sign in to comment.