64. Minimum Path Sum
https://leetcode.com/problems/minimum-path-sum/description/
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.
Note: You can only move either down or right at any point in time.
Example:
Thoughts
走格且求最优结果,DP。action为从上面下来和从左边过来。优化空间时要在循环里初始化第0列的结果。
Code
Last updated
Was this helpful?