<p>You are given an integer array <code>nums</code>. In one move, you can pick an index <code>i</code> where <code>0 &lt;= i &lt; nums.length</code> and increment <code>nums[i]</code> by <code>1</code>.</p>

<p>Return <em>the minimum number of moves to make every value in </em><code>nums</code><em> <strong>unique</strong></em>.</p>

<p>The test cases are generated so that the answer fits in a 32-bit integer.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> nums = [1,2,2]
<strong>Output:</strong> 1
<strong>Explanation:</strong> After 1 move, the array could be [1, 2, 3].
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> nums = [3,2,1,2,1,7]
<strong>Output:</strong> 6
<strong>Explanation:</strong> After 6 moves, the array could be [3, 4, 1, 2, 5, 7].
It can be shown that it is impossible for the array to have all unique values with 5 or less moves.
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
	<li><code>0 &lt;= nums[i] &lt;= 10<sup>5</sup></code></li>
</ul>

class Solution:
    def minIncrementForUnique(self, nums: List[int]) -> int:
        maxNum = 0
        res = 0
        seen = set()
        
        nums.sort()
        
        for num in nums:
            if num not in seen:
                seen.add(num)
                maxNum = num + 1
            else:
                seen.add(maxNum)
                res += maxNum - num
                maxNum += 1
        
        return res
        
'''
Problem:
- given nums and in one move you can pick any index and increment by 1
- return the min # of moves to make every value in nums unique

Approach:

- sort O(n log n) & greedy O(n)
- keep track of the numbers that we have seen and what the next number should be
- if we have seen the current number, then we get the difference between the next number
- mark the next number as seen and increment the next number

- when we are putting number in our seen set, increment that number and if that number is greater than our maxNum, then update our maxNum
- maxNum will be the next number we can place

seen = 1,2,3,4,7
res = 1+1+2+2

            8
1 1 2 2 3 7

1 2 2


3 2 1 2 1 7

maxNum = 4

i
1 2 3
1 1 2 2 2 2 2 3 7
            
            7 8 9
s s s s s s s
1 2 3 4 5 5 5 8 19

          10
1 1 2 2 9

'''
36500