Skip to content

Commit 7e3a962

Browse files
committed
1282
1 parent fa6fb3a commit 7e3a962

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

1282.cpp

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
class Solution {
2+
public:
3+
vector<vector<int>> groupThePeople(vector<int>& groupSizes) {
4+
map<int,vector<int>>mp;
5+
for(int i=0;i<groupSizes.size();i++){
6+
mp[groupSizes[i]].push_back(i);
7+
}
8+
vector<vector<int>>V;
9+
for(auto it=mp.begin();it!=mp.end();it++){
10+
vector<int>vec;
11+
for(int i=0;i<it->second.size();i++){
12+
vec.push_back(it->second[i]);
13+
if(vec.size()==it->first){
14+
V.push_back(vec);
15+
vec.clear();
16+
17+
}
18+
}
19+
}
20+
return V;
21+
}
22+
};

0 commit comments

Comments
 (0)