Skip to content

Commit 5cf68a7

Browse files
committed
Create README - LeetHub
1 parent f469a9f commit 5cf68a7

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

0370-range-addition/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<h2><a href="https://leetcode.com/problems/range-addition">370. Range Addition</a></h2><h3>Medium</h3><hr><p>You are given an integer <code>length</code> and an array <code>updates</code> where <code>updates[i] = [startIdx<sub>i</sub>, endIdx<sub>i</sub>, inc<sub>i</sub>]</code>.</p>
2+
3+
<p>You have an array <code>arr</code> of length <code>length</code> with all zeros, and you have some operation to apply on <code>arr</code>. In the <code>i<sup>th</sup></code> operation, you should increment all the elements <code>arr[startIdx<sub>i</sub>], arr[startIdx<sub>i</sub> + 1], ..., arr[endIdx<sub>i</sub>]</code> by <code>inc<sub>i</sub></code>.</p>
4+
5+
<p>Return <code>arr</code> <em>after applying all the</em> <code>updates</code>.</p>
6+
7+
<p>&nbsp;</p>
8+
<p><strong class="example">Example 1:</strong></p>
9+
<img alt="" src="https://assets.leetcode.com/uploads/2021/03/27/rangeadd-grid.jpg" style="width: 413px; height: 573px;" />
10+
<pre>
11+
<strong>Input:</strong> length = 5, updates = [[1,3,2],[2,4,3],[0,2,-2]]
12+
<strong>Output:</strong> [-2,0,3,5,3]
13+
</pre>
14+
15+
<p><strong class="example">Example 2:</strong></p>
16+
17+
<pre>
18+
<strong>Input:</strong> length = 10, updates = [[2,4,6],[5,6,8],[1,9,-4]]
19+
<strong>Output:</strong> [0,-4,2,2,2,4,4,-4,-4,-4]
20+
</pre>
21+
22+
<p>&nbsp;</p>
23+
<p><strong>Constraints:</strong></p>
24+
25+
<ul>
26+
<li><code>1 &lt;= length &lt;= 10<sup>5</sup></code></li>
27+
<li><code>0 &lt;= updates.length &lt;= 10<sup>4</sup></code></li>
28+
<li><code>0 &lt;= startIdx<sub>i</sub> &lt;= endIdx<sub>i</sub> &lt; length</code></li>
29+
<li><code>-1000 &lt;= inc<sub>i</sub> &lt;= 1000</code></li>
30+
</ul>

0 commit comments

Comments
 (0)