本文共 566 字,大约阅读时间需要 1 分钟。
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right whichminimizes the sum of all numbers along its path.
Note: You can only move either down or right at any point in time.
题意:给定m*n矩阵,里面都是非负数,求从左上角,走到右下角的路径,要求这条路径过程中所有数加起来的和最小
分类:数组,动态规划
动态规划:
MPS[i][j] = Min(MPS[i-1][j],MPS[i][j-1])+ val[i][j];
边界处理条件:
for(int j=1; j
class Solution {public: int minPathSum(vector> &grid) { if(grid.size()==0) return 0; vector > res(grid); int i, j; for(int j=1; j
转载地址:http://orkcn.baihongyu.com/