class Solution {
public:
int uniquePathsWithObstacles(vector<vector<int>>& obstacleGrid) {
if (obstacleGrid[0][0]) return 0;
int m = obstacleGrid.size();
int n = obstacleGrid[0].size();
vector<vector<int>> nPaths(m, vector<int>(n));
nPaths[0][0] = 1;
for (int s = 1; s <= m+n; ++s) {
for (int r = max(0, s  n + 1); r <= s && r < m; ++r) {
int c = s  r;
if (c >= n)
continue;
if (c < 0)
break;
nPaths[r][c] = obstacleGrid[r][c] ?
0 : (r > 0 ? nPaths[r1][c] : 0) + (c > 0 ? nPaths[r][c1] : 0);
}
}
return nPaths[m1][n1];
}
};
C++ solution beats 100%


@StefanPochmann I got to have the time distribution when I submitted the solution. But now it's gone...