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
The minimum path sum from top to bottom is11
(i.e.,2+3+5+1= 11).
分析
这里没判断triangle的null和大小也行?
从底部向上,选更小那个加
类似minimal path sum, 要求最小的,row0 col0都设为最大防止干扰。dp还是m*n : f = [[float('inf')] * (m + 1) for _ in range(n+1)]
Last updated