Find the minimum path sum from the top to the bottom of a triangle of numbers.
Triangle Minimum Path Sum
gfgYou are given a triangular array of integers. Start at the top element and move to the next row one step at a time. From position i in a row, you may move to either of the two adjacent positions in the row below.
Return the minimum possible sum of values along any path from the top to the bottom.
triangle, where triangle[r] contains r + 1 integers.1 <= triangle.lengthr has exactly r + 1 elementsExample 1
Input
triangle = [[2],[3,4],[6,5,7],[4,1,8,3]]
Output
11
Explanation
The minimum path is 2 -> 3 -> 5 -> 1, which sums to 11.
Example 2
Input
triangle = [[-10]]
Output
-10
Explanation
There is only one path, so the answer is the single value.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.