Ctrl K

Two Groups With the Same Average

Hard
You are given an array scores with the scores of some participants. Split all participants into two non-empty groups (each person goes to exactly one) so that both groups have the same average score. The average of a group is the sum of its scores divided by its size. Return True if such a split exists and False otherwise.
Example 1
scores=[3, 9, 4, 8] → True

The groups [3, 9] and [4, 8] both average 6.

Example 2
scores=[1, 2, 6] → False

The overall average is 3, so each group would have to average 3 as well. No single number equals 3 and no pair sums to 6.

Example 3
scores=[5, 1, 9, 5] → True

[5] and [1, 9, 5] both average 5. The groups may differ in size.

Constraints
  • 1 ≤ len(scores) ≤ 30
  • 0 ≤ scores[i] ≤ 10⁴
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsSquare-Sum Chains HardProduct of Distinct Primes HardBump Numbers to Fit the Divisors HardFewest Lines Through the Dots MediumProducts Free of Squares Medium
loading Python…
Input
scores=[3, 9, 4, 8]
Expected
True

Run checks the first 3 tests in your browser. Submit checks all 98 tests on the server, hidden ones included.