Triangle
题目
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
> [> [2],> [3,4],> [6,5,7],> [4,1,8,3]> ]>>
>
The minimum path sum from top to bottom is
11
(i.e., 2 + 3 + 5 + 1 = 11).
题目是说,从三角形的最上层走到最下层,每次只走到下一层的相邻元素,求从顶点走到最下层的最短路径长度。
方法1:DFS遍历
从上往下深度优先遍历搜索,记录所有情况之中最小值
|
时间复杂度