-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<h2><a href="https://leetcode.com/problems/minimum-increment-to-make-array-unique/">945. Minimum Increment to Make Array Unique</a></h2><h3>Medium</h3><hr><div><p>You are given an integer array <code>nums</code>. In one move, you can pick an index <code>i</code> where <code>0 <= i < 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> </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 with 5 or less moves that it is impossible for the array to have all unique values. | ||
</pre> | ||
|
||
<p> </p> | ||
<p><strong>Constraints:</strong></p> | ||
|
||
<ul> | ||
<li><code>1 <= nums.length <= 10<sup>5</sup></code></li> | ||
<li><code>0 <= nums[i] <= 10<sup>5</sup></code></li> | ||
</ul> | ||
</div> |