Group the People Given the Group Size They Belong To
There are n
people whose IDs go from 0
to n - 1
and each person belongs exactly to one group. Given the array groupSizes
of length n
telling the group size each person belongs to, return the groups there are and the people's IDs each group includes.
You can return any solution in any order and the same applies for IDs. Also, it is guaranteed that there exists at least one solution.
Example 1:
Example 2:
Constraints:
groupSizes.length == n
1 <= n <= 500
1 <= groupSizes[i] <= n
Last updated