Minimum Operations to Make Array Elements Unique
Problem Make all array elements unique using only increments (+1 per operation), minimizing the total number of increments.
Input / Output
- Input: int array nums. Output: minimum total increments.
Constraints
- n up to 10^5; O(n log n) expected.
Example
- [3,2,1,2,1,7] → 6 (e.g. [3,4,1,2,5,7]); [1,2,2] → 1.
asked …