Skip to content

Commit 433d216

Browse files
committed
Create README - LeetHub
1 parent 348d66c commit 433d216

File tree

1 file changed

+46
-0
lines changed
  • 2661-smallest-missing-non-negative-integer-after-operations

1 file changed

+46
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<h2><a href="https://leetcode.com/problems/smallest-missing-non-negative-integer-after-operations">2661. Smallest Missing Non-negative Integer After Operations</a></h2><h3>Medium</h3><hr><p>You are given a <strong>0-indexed</strong> integer array <code>nums</code> and an integer <code>value</code>.</p>
2+
3+
<p>In one operation, you can add or subtract <code>value</code> from any element of <code>nums</code>.</p>
4+
5+
<ul>
6+
<li>For example, if <code>nums = [1,2,3]</code> and <code>value = 2</code>, you can choose to subtract <code>value</code> from <code>nums[0]</code> to make <code>nums = [-1,2,3]</code>.</li>
7+
</ul>
8+
9+
<p>The MEX (minimum excluded) of an array is the smallest missing <strong>non-negative</strong> integer in it.</p>
10+
11+
<ul>
12+
<li>For example, the MEX of <code>[-1,2,3]</code> is <code>0</code> while the MEX of <code>[1,0,3]</code> is <code>2</code>.</li>
13+
</ul>
14+
15+
<p>Return <em>the maximum MEX of </em><code>nums</code><em> after applying the mentioned operation <strong>any number of times</strong></em>.</p>
16+
17+
<p>&nbsp;</p>
18+
<p><strong class="example">Example 1:</strong></p>
19+
20+
<pre>
21+
<strong>Input:</strong> nums = [1,-10,7,13,6,8], value = 5
22+
<strong>Output:</strong> 4
23+
<strong>Explanation:</strong> One can achieve this result by applying the following operations:
24+
- Add value to nums[1] twice to make nums = [1,<strong><u>0</u></strong>,7,13,6,8]
25+
- Subtract value from nums[2] once to make nums = [1,0,<strong><u>2</u></strong>,13,6,8]
26+
- Subtract value from nums[3] twice to make nums = [1,0,2,<strong><u>3</u></strong>,6,8]
27+
The MEX of nums is 4. It can be shown that 4 is the maximum MEX we can achieve.
28+
</pre>
29+
30+
<p><strong class="example">Example 2:</strong></p>
31+
32+
<pre>
33+
<strong>Input:</strong> nums = [1,-10,7,13,6,8], value = 7
34+
<strong>Output:</strong> 2
35+
<strong>Explanation:</strong> One can achieve this result by applying the following operation:
36+
- subtract value from nums[2] once to make nums = [1,-10,<u><strong>0</strong></u>,13,6,8]
37+
The MEX of nums is 2. It can be shown that 2 is the maximum MEX we can achieve.
38+
</pre>
39+
40+
<p>&nbsp;</p>
41+
<p><strong>Constraints:</strong></p>
42+
43+
<ul>
44+
<li><code>1 &lt;= nums.length, value &lt;= 10<sup>5</sup></code></li>
45+
<li><code>-10<sup>9</sup> &lt;= nums[i] &lt;= 10<sup>9</sup></code></li>
46+
</ul>

0 commit comments

Comments
 (0)