Trains the technique from
LeetCode 805Split Array With Same AverageThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A tray holds the weights weights. Put every weight into one of two bins, and neither bin may end up empty.
Return true when some way of doing that leaves the two bins with the same average weight.
Example 1
Putting the 2 in one bin and the 1 and the 3 in the other gives both bins an average of 2.
Example 2
The tray totals 7 across three weights. A bin of one weight would have to hold seven thirds and a bin of two would have to total fourteen thirds, and neither is whole.
Example 3
Every weight is the same, so any split at all leaves both bins on that average.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def split_array_same_average(weights: list[int]) -> bool:public boolean splitArraySameAverage(int[] weights)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.