Skip to content

Commit b2e80e5

Browse files
committed
Create README - LeetHub
1 parent 885200f commit b2e80e5

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<h2><a href="https://leetcode.com/problems/zero-array-transformation-i">3639. Zero Array Transformation I</a></h2><h3>Medium</h3><hr><p>You are given an integer array <code>nums</code> of length <code>n</code> and a 2D array <code>queries</code>, where <code>queries[i] = [l<sub>i</sub>, r<sub>i</sub>]</code>.</p>
2+
3+
<p>For each <code>queries[i]</code>:</p>
4+
5+
<ul>
6+
<li>Select a <span data-keyword="subset">subset</span> of indices within the range <code>[l<sub>i</sub>, r<sub>i</sub>]</code> in <code>nums</code>.</li>
7+
<li>Decrement the values at the selected indices by 1.</li>
8+
</ul>
9+
10+
<p>A <strong>Zero Array</strong> is an array where all elements are equal to 0.</p>
11+
12+
<p>Return <code>true</code> if it is <em>possible</em> to transform <code>nums</code> into a <strong>Zero Array </strong>after processing all the queries sequentially, otherwise return <code>false</code>.</p>
13+
14+
<p>&nbsp;</p>
15+
<p><strong class="example">Example 1:</strong></p>
16+
17+
<div class="example-block">
18+
<p><strong>Input:</strong> <span class="example-io">nums = [1,0,1], queries = [[0,2]]</span></p>
19+
20+
<p><strong>Output:</strong> <span class="example-io">true</span></p>
21+
22+
<p><strong>Explanation:</strong></p>
23+
24+
<ul>
25+
<li><strong>For i = 0:</strong>
26+
27+
<ul>
28+
<li>Select the subset of indices as <code>[0, 2]</code> and decrement the values at these indices by 1.</li>
29+
<li>The array will become <code>[0, 0, 0]</code>, which is a Zero Array.</li>
30+
</ul>
31+
</li>
32+
</ul>
33+
</div>
34+
35+
<p><strong class="example">Example 2:</strong></p>
36+
37+
<div class="example-block">
38+
<p><strong>Input:</strong> <span class="example-io">nums = [4,3,2,1], queries = [[1,3],[0,2]]</span></p>
39+
40+
<p><strong>Output:</strong> <span class="example-io">false</span></p>
41+
42+
<p><strong>Explanation:</strong></p>
43+
44+
<ul>
45+
<li><strong>For i = 0:</strong>
46+
47+
<ul>
48+
<li>Select the subset of indices as <code>[1, 2, 3]</code> and decrement the values at these indices by 1.</li>
49+
<li>The array will become <code>[4, 2, 1, 0]</code>.</li>
50+
</ul>
51+
</li>
52+
<li><strong>For i = 1:</strong>
53+
<ul>
54+
<li>Select the subset of indices as <code>[0, 1, 2]</code> and decrement the values at these indices by 1.</li>
55+
<li>The array will become <code>[3, 1, 0, 0]</code>, which is not a Zero Array.</li>
56+
</ul>
57+
</li>
58+
</ul>
59+
</div>
60+
61+
<p>&nbsp;</p>
62+
<p><strong>Constraints:</strong></p>
63+
64+
<ul>
65+
<li><code>1 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
66+
<li><code>0 &lt;= nums[i] &lt;= 10<sup>5</sup></code></li>
67+
<li><code>1 &lt;= queries.length &lt;= 10<sup>5</sup></code></li>
68+
<li><code>queries[i].length == 2</code></li>
69+
<li><code>0 &lt;= l<sub>i</sub> &lt;= r<sub>i</sub> &lt; nums.length</code></li>
70+
</ul>

0 commit comments

Comments
 (0)