← 返回 amazon 的题目列表Group Students
类型:online_judge
Given an array of student scores and an integer n that represents the number of groups you want. Your task is to divide the students into n groups such that the sum of scores in each group is as balanced as possible. Return the sum of scores for each group.
Input
An integer array scores, representing each student's score.
An integer n
Output Return an integer array representing the sum of scores for each group.
Example
Input: scores = [10, 20, 30, 40], n = 2
Output: [50, 50]
Explanation You can divide the students into two groups, each with two students, such that the total scores for each group is equal.
Example
Input
10 20 30 40
2