Skip to content

Commit d80a731

Browse files
committed
Create README - LeetHub
1 parent 93379aa commit d80a731

File tree

1 file changed

+50
-0
lines changed
  • 2119-minimum-number-of-operations-to-make-array-continuous

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<h2><a href="https://leetcode.com/problems/minimum-number-of-operations-to-make-array-continuous">2119. Minimum Number of Operations to Make Array Continuous</a></h2><h3>Hard</h3><hr><p>You are given an integer array <code>nums</code>. In one operation, you can replace <strong>any</strong> element in <code>nums</code> with <strong>any</strong> integer.</p>
2+
3+
<p><code>nums</code> is considered <strong>continuous</strong> if both of the following conditions are fulfilled:</p>
4+
5+
<ul>
6+
<li>All elements in <code>nums</code> are <strong>unique</strong>.</li>
7+
<li>The difference between the <strong>maximum</strong> element and the <strong>minimum</strong> element in <code>nums</code> equals <code>nums.length - 1</code>.</li>
8+
</ul>
9+
10+
<p>For example, <code>nums = [4, 2, 5, 3]</code> is <strong>continuous</strong>, but <code>nums = [1, 2, 3, 5, 6]</code> is <strong>not continuous</strong>.</p>
11+
12+
<p>Return <em>the <strong>minimum</strong> number of operations to make </em><code>nums</code><em> </em><strong><em>continuous</em></strong>.</p>
13+
14+
<p>&nbsp;</p>
15+
<p><strong class="example">Example 1:</strong></p>
16+
17+
<pre>
18+
<strong>Input:</strong> nums = [4,2,5,3]
19+
<strong>Output:</strong> 0
20+
<strong>Explanation:</strong>&nbsp;nums is already continuous.
21+
</pre>
22+
23+
<p><strong class="example">Example 2:</strong></p>
24+
25+
<pre>
26+
<strong>Input:</strong> nums = [1,2,3,5,6]
27+
<strong>Output:</strong> 1
28+
<strong>Explanation:</strong>&nbsp;One possible solution is to change the last element to 4.
29+
The resulting array is [1,2,3,5,4], which is continuous.
30+
</pre>
31+
32+
<p><strong class="example">Example 3:</strong></p>
33+
34+
<pre>
35+
<strong>Input:</strong> nums = [1,10,100,1000]
36+
<strong>Output:</strong> 3
37+
<strong>Explanation:</strong>&nbsp;One possible solution is to:
38+
- Change the second element to 2.
39+
- Change the third element to 3.
40+
- Change the fourth element to 4.
41+
The resulting array is [1,2,3,4], which is continuous.
42+
</pre>
43+
44+
<p>&nbsp;</p>
45+
<p><strong>Constraints:</strong></p>
46+
47+
<ul>
48+
<li><code>1 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
49+
<li><code>1 &lt;= nums[i] &lt;= 10<sup>9</sup></code></li>
50+
</ul>

0 commit comments

Comments
 (0)