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:
Input:
[
[1,3,1],
[1,5,1],
[4,2,1]
]
Output: 7
Explanation: Because the path 1→3→1→1→1 minimizes the sum.
思路:dp
1、和63题一样的思路、不过换成了min path sum
2、dp【i】【j】定义为:在这个位置上的min path sum
3、则对于不是第一行也不是第一列的那些位置
dp【i】【j】 = Math.min(dp【i-1】【j】 ,dp【i】【j-1】) + grid【i-1】【j-1】
4、对于第一行来说、只有左边往右边来、
5、对于第一列来说、只有上边下来
6、i=1、j=1、则dp【i】【j】 = grid【i-1】【j-1】