Q120. Triangle
Last updated
Was this helpful?
Last updated
Was this helpful?
直达:
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.
For example, given the following triangle
The minimum path sum from top to bottom is11
(i.e.,2+3+5+1= 11).
Note: Bonus point if you are able to do this using onlyO(n) extra space, wherenis the total number of rows in the triangle.
算法思路类似于Q119, 不同之处在于矩阵的更新方法,由求和变成求最小值。