class Solution {
public:
int minPathSum(vector<vector<int>>& grid) {
if (grid.empty()) {
return 0;
}
int m = grid.size(), n = grid[0].size();
for (int i = 1; i < n; ++i) {
grid[0][i] = grid[0][i1] + grid[0][i];
}
for (int i = 1; i < m; ++i) {
grid[i][0] = grid[i1][0] + grid[i][0];
}
for (int i = 1; i < m; ++i) {
for (int j = 1; j < n; ++j) {
grid[i][j] = min(grid[i1][j],grid[i][j1]) + grid[i][j];
}
}
return grid[m1][n1];
}
};
Is O(0) space?c++ solution


We usually pick from these: Wikipedia Big O notation: Orders of common functions
Check this out as well: SO aboutO(0)