Given an integer array nums, you need to determine if it's possible to split the array into two non-empty groups such that both groups have the same average.
Think of this as dividing a class of students with different test scores into two groups where both groups have identical average scores. You must move each student to exactly one of the two groups, and both groups must have at least one student.
Goal: Return true if such a split is possible, false otherwise.
Note: The average of an array is the sum of all elements divided by the length of the array.
Example: For nums = [1,2,3,4,5,6,7,8], we can split into [1,4,5,8] and [2,3,6,7]. Both groups have average 4.5!
Input & Output
Visualization
Time & Space Complexity
We generate all 2^n possible subsets of the array
Recursion stack depth and space for storing current subset
Constraints
- 1 ≤ nums.length ≤ 30
- 0 ≤ nums[i] ≤ 104
- Both groups must be non-empty
- The average is calculated as sum of elements divided by count