LeetCode-3.22-945-M-使数组唯一的最小增量(Minimum Increment to Make Array Unique)

文章目录


给定整数数组 A,每次 move 操作将会选择任意 A[i],并将其递增 1。
返回使 A 中的每个值都是唯一的最少操作次数。

Given an array of integers A, a move consists of choosing any A[i], and incrementing it by 1.
Return the least number of moves to make every value in A unique.

示例 1:
输入:[1,2,2]
输出:1
解释:经过一次 move 操作,数组将变为 [1, 2, 3]。

思路

-wait

解法

发布了194 篇原创文章 · 获赞 20 · 访问量 7974

猜你喜欢

转载自blog.csdn.net/Xjheroin/article/details/105022225