107. Triangle
MediumDynamic Programming
Given a triangle array, return the minimum path sum from top to bottom. For each step, you may move to an adjacent number of the row below. More formally, if you are on index i on the current row, you may move to either index i or index i + 1 on the next row.
Examples
Input: [[2],[3,4],[6,5,7],[4,1,8,3]]
Output: 11
Explanation: The path 2→3→5→1 sums to 11, the minimum.
Constraints
- 1 <= triangle.length <= 200
- triangle[0].length == 1
- triangle[i].length == triangle[i - 1].length + 1
- -10^4 <= triangle[i][j] <= 10^4
Loading...
Run checks all cases above. Submit evaluates all test cases.