int Solution::minPathSum(vector<vector > &A) {

// author : ninja

if(A.size() == 0 || A[0].size() == 0) return 0;

```
int R = A.size();
int C = A[0].size();
for(int i=0;i<R+1;i++) {
for(int j=0;j<C+1;j++) {
if(i >= 0 && j >= 0) A[i][j] += min(A[i-1][j], A[i][j-1]);
else if(i >= 0) A[i][j] += A[i-1][j];
else if(j >= 0) A[i][j] += A[i][j-1];
}
}
return A[R][C];
```

}