You are given an integer array nums. In one move you pick an index i and increase nums[i] by 1. Return the minimum number of moves needed so that every value in nums is unique.
You are given an integer array nums. In one move you pick an index i and increase nums[i] by 1. Return the minimum number of moves needed so that every value in nums is unique.
Example 1:
Input: {"nums":[1,2,2]}
Output: 1
Constraints:
1≤nums.length≤105
0≤nums[i]≤105
The answer fits in a 32-bit integer.
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"nums":[1,2,2]}
3 numbers. Values can only go up, so each duplicate must climb to a free value above it.