Triangle
Return the minimum path sum from top to bottom of the triangle.
Examples
Input: [[2],[3,4],[6,5,7],[4,1,8,3]]
Output: 11
Input: [[-10]]
Output: -10
Hints
Initialize a DP array of the same length as the bottom row of the triangle, filled with the values of the bottom row.
For each row from the second last to the top, update the DP array such that each element is the sum of its current value and the minimum of the two adjacent elements from the row below.
After processing all rows, the first element of the DP array will contain the minimum path sum from the top to the bottom of the triangle.
Related Problems
Triangle
Return the minimum path sum from top to bottom of the triangle.