Package g0101_0200.s0120_triangle
Class Solution
java.lang.Object
g0101_0200.s0120_triangle.Solution
120 - Triangle.<p>Medium</p>
<p>Given a <code>triangle</code> array, return <em>the minimum path sum from top to bottom</em>.</p>
<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>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> triangle = [[2],[3,4],[6,5,7],[4,1,8,3]]</p>
<p><strong>Output:</strong> 11</p>
<p><strong>Explanation:</strong></p>
<pre><code> The triangle looks like:
2
3 4
6 5 7
4 1 8 3
The minimum path sum from top to bottom is 2 + 3 + 5 + 1 = 11 (underlined above).
</code></pre>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> triangle = [[-10]]</p>
<p><strong>Output:</strong> -10</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= triangle.length <= 200</code></li>
<li><code>triangle[0].length == 1</code></li>
<li><code>triangle[i].length == triangle[i - 1].length + 1</code></li>
<li><code>-10<sup>4</sup> <= triangle[i][j] <= 10<sup>4</sup></code></li>
</ul>
<p><strong>Follow up:</strong> Could you do this using only <code>O(n)</code> extra space, where <code>n</code> is the total number of rows in the triangle?</p>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
minimumTotal
-