标签:class tor div nbsp path solution cto grid color
class Solution { public: int minPathSum(vector<vector<int>>& grid) { int row=grid.size(); int col=grid[0].size(); int N=1000; int D[N][N]; D[0][0]=grid[0][0]; for(int j=1;j<col;j++){ D[0][j]=D[0][j-1]+grid[0][j]; } for(int i=1;i<row;i++){ D[i][0]=D[i-1][0]+grid[i][0]; } for(int i=1;i<row;i++){ for(int j=1;j<col;j++){ D[i][j]=min(D[i][j-1],D[i-1][j])+grid[i][j]; } } return D[row-1][col-1]; } };
标签:class tor div nbsp path solution cto grid color
原文地址:https://www.cnblogs.com/asenyang/p/9777939.html