DP
class Solution {
public int minPathSum(int[][] grid) {
int row = grid.length;
int col = grid[0].length;
int[] dp = new int[col];
dp[0]=grid[0][0];
for(int j = 1;j<col;j++)
{
dp[j]=grid[0][j]+dp[j-1];
}
for(int i = 1 ;i<row;i++)
{
for(int j = 0;j<col;j++)
{
if(j==0)
{
dp[j]+=grid[i][j];
}
else
{
dp[j]=Math.min(dp[j]+grid[i][j],dp[j-1]+grid[i][j]);
}
}
}
return dp[col-1];
}
}