Trains the technique from
LeetCode 945Minimum Increment to Make Array UniqueThis 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 row of dials shows whole-number readings, and several dials may show the same reading. One nudge picks a single dial and raises its reading by 1.
Return the fewest nudges that leave no two dials showing the same reading.
Example 1
One of the two dials climbs to 1, which takes a single nudge.
Example 2
Leave one dial where it is and lift the other four to 3, 4, 5 and 6, costing 1 plus 2 plus 3 plus 4.
Example 3
No two dials already share a reading, so nothing has to move.
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_increment_for_unique(dials: list[int]) -> int:public int minIncrementForUnique(int[] dials)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.