Trains the technique from
LeetCode 1760Minimum Limit of Balls in a BagThis 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 depot floor holds several stacks of cartons. stacks[i] is the number of cartons in stack i.
One split takes a single stack off the floor and puts back two stacks in its place, each holding at least one carton, together holding exactly what the original stack held. A stack put back may be split again later. You are allowed at most splits splits, and you may also use fewer, or none at all.
The peak of the floor is the number of cartons in its tallest stack. Return the smallest peak you can leave behind.
Example 1
Split each stack of 9 into 5 and 4, using both allowed splits. The floor then holds 5, 4, 5 and 4 cartons, so its peak is 5.
Example 2
One split is allowed. Splitting a stack of 4 into 2 and 2 leaves the floor holding 2, 2 and 4 cartons, whose peak is 4. Carrying out no split at all also leaves a peak of 4.
Example 3
Every stack already holds a single carton and a split has to leave at least one carton on each side, so no split is possible and the peak is 1.
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 minimum_size(stacks: list[int], splits: int) -> int:public int minimumSize(int[] stacks, int splits)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.