Leetcode 982 Solution
This article provides solution to leetcode question 982 (minimum-increment-to-make-array-unique)
Access this page by simply typing in "lcs 982" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/minimum-increment-to-make-array-unique
Solution
class Solution:
def minIncrementForUnique(self, nums: List[int]) -> int:
need = 0
ans = 0
for num in sorted(nums):
ans += max(need - num, 0)
need = max(need, num) + 1
return ans