Split All Values into Two Equal-Average Groups
Company: Amazon
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: hard
Interview Round: Other
### Problem
Assign every occurrence in nums to one of two nonempty groups. Return whether the groups can have exactly equal arithmetic means. The grouping need not preserve array contiguity.
```cpp
class Solution {
public:
bool splitArraySameAverage(vector<int>& nums);
};
```
### Examples
**Example 1:**
```text
nums = [1,3,5,7]
Output: true
Explanation: [1,7] and [3,5] both average4.
```
**Example 2:**
```text
nums = [0,1]
Output: false
Explanation: The only nonempty split has different singleton averages.
```
### Constraints
- Array length lies in [1,30].
- Values are integers between 0 and 10000 inclusive.
### Contract considerations
Preserve all occurrences and both nonempty groups.
```hint Read the boundary condition
How can cross multiplication turn an average condition into a zero-sum subset?
```
### Boundary reminders
Preserve all occurrences and both nonempty groups.
Overview: Split All Values into Two Equal-Average Groups. Assign every occurrence in nums to one of two nonempty groups.