Skip to content

Commit a7bfc35

Browse files
committed
Create README - LeetHub
1 parent 922b3f8 commit a7bfc35

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

0120-triangle/README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<h2><a href="https://leetcode.com/problems/triangle/">120. Triangle</a></h2><h3>Medium</h3><hr><p>Given a <code>triangle</code> array, return <em>the minimum path sum from top to bottom</em>.</p>
2+
3+
<p>For each step, you may move to an adjacent number of the row below. More formally, if you are on index <code>i</code> on the current row, you may move to either index <code>i</code> or index <code>i + 1</code> on the next row.</p>
4+
5+
<p>&nbsp;</p>
6+
<p><strong class="example">Example 1:</strong></p>
7+
8+
<pre>
9+
<strong>Input:</strong> triangle = [[2],[3,4],[6,5,7],[4,1,8,3]]
10+
<strong>Output:</strong> 11
11+
<strong>Explanation:</strong> The triangle looks like:
12+
<u>2</u>
13+
<u>3</u> 4
14+
6 <u>5</u> 7
15+
4 <u>1</u> 8 3
16+
The minimum path sum from top to bottom is 2 + 3 + 5 + 1 = 11 (underlined above).
17+
</pre>
18+
19+
<p><strong class="example">Example 2:</strong></p>
20+
21+
<pre>
22+
<strong>Input:</strong> triangle = [[-10]]
23+
<strong>Output:</strong> -10
24+
</pre>
25+
26+
<p>&nbsp;</p>
27+
<p><strong>Constraints:</strong></p>
28+
29+
<ul>
30+
<li><code>1 &lt;= triangle.length &lt;= 200</code></li>
31+
<li><code>triangle[0].length == 1</code></li>
32+
<li><code>triangle[i].length == triangle[i - 1].length + 1</code></li>
33+
<li><code>-10<sup>4</sup> &lt;= triangle[i][j] &lt;= 10<sup>4</sup></code></li>
34+
</ul>
35+
36+
<p>&nbsp;</p>
37+
<strong>Follow up:</strong> Could you&nbsp;do this using only <code>O(n)</code> extra space, where <code>n</code> is the total number of rows in the triangle?

0 commit comments

Comments
 (0)