All prompts are owned by LeetCode. To view the prompt, click the title link above.
First completed : June 28, 2024
Last updated : June 28, 2024
Related Topics : Array, Hash Table, Greedy
Acceptance Rate : 87.43 %
class Solution:
def groupThePeople(self, groupSizes: List[int]) -> List[List[int]]:
people = sorted([(groupSizes[i], i) for i in range(len(groupSizes))], reverse=True)
outputs = []
while people :
currSize = people[-1][0]
outputs.append([people.pop()[1] for _ in range(currSize)])
return outputs