Triangle
MediumDynamic Programming
Decode it first. Clues, constraints, pattern and plan before any code.A triangle of numbers has one value in row 0, two in row 1, and so on. Start at the top and move down one row at a time. From index i in a row you may step to index i or i + 1 in the row below. Return the minimum path sum from top to bottom.
triangle = [[2],
[3, 4],
[6, 5, 7],
[4, 1, 8, 3]] → 11 (2 + 3 + 5 + 1)
triangle = [[-10]] → -10Constraints
1 <= triangle.length <= 200triangle[0].length == 1andtriangle[i].length == triangle[i - 1].length + 1-10^4 <= triangle[i][j] <= 10^4