Trains the technique from
LeetCode 2918Minimum Equal Sum of Two Arrays After Replacing ZerosThis 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.
Two sheets of figures read left and right. A 0 on either sheet is a blank that has to be filled in with a whole number of 1 or more; every other figure stays as it is.
Fill in all the blanks so that the two sheets come to the same total. Return the smallest total both can be brought to, or -1 when no filling makes them meet.
Example 1
The left sheet has six written and two blanks, so its floor is eight. The right sheet has eleven written and one blank, so its floor is twelve. Twelve is the larger, and the left sheet reaches it by writing 1 in one blank and 5 in the other.
Example 2
The left sheet has four written and two blanks, so it can never total less than six. The right sheet has no blanks at all and is stuck at five, so the two can never meet.
Example 3
Neither sheet has a blank and both already total six, so six is the only total either can show.
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 min_sum(left: list[int], right: list[int]) -> int:public long minSum(int[] left, int[] right)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.