Trains the technique from
LeetCode 2602Minimum Operations to Make All Array Elements EqualThis 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 rail of gauges reads gauges. One turn changes a single gauge by one, up or down.
Each entry of targets asks a separate question, and the rail is never actually changed: how many turns would it take to bring every gauge to that target reading?
Return the answers in the order the questions are asked.
Example 1
Bringing everything to two costs one turn on the 1, nothing on the 2 and one turn on the 3.
Example 2
A single gauge reading five costs four turns to reach one, nothing to reach five, and four again to reach nine.
Example 3
Both gauges already read the target, so nothing needs turning.
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_operations(gauges: list[int], targets: list[int]) -> list[int]:public List<Long> minOperations(int[] gauges, int[] targets)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.