Trains the technique from
LeetCode 462Minimum Moves to Equal Array Elements IIThis 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.
Return the fewest turns that leave every gauge on the same reading.
Example 1
Every gauge already reads the same, so nothing needs turning.
Example 2
The two readings are four apart, and any reading between them costs exactly four turns altogether.
Example 3
Settling on four leaves the four gauges already there untouched and brings the ten down six turns. Settling anywhere higher would move four gauges instead of one.
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_moves2(gauges: list[int]) -> int:public long minMoves2(int[] gauges)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.