17 lines
257 B
Go
17 lines
257 B
Go
package main
|
|
|
|
import "slices"
|
|
|
|
func minIncrementForUnique(nums []int) int {
|
|
slices.Sort(nums)
|
|
|
|
moves := 0
|
|
for i := 1; i < len(nums); i++ {
|
|
if nums[i] <= nums[i-1] {
|
|
moves += nums[i-1] + 1 - nums[i]
|
|
nums[i] = nums[i-1] + 1
|
|
}
|
|
}
|
|
|
|
return moves
|
|
}
|