class Solution {
public:
int uniquePathsWithObstacles(vector<vector<int>>& o) {
int n = o.size();
int m = o[0].size();
if (!n || !m) return 0;
vector<vector<int>> f(n, vector<int>(m));
for (int i = 0; i < n; i ++) {
for (int j = 0; j < m; j ++) {
if (!o[i][j]) { //当不是障碍物时,进行递推处理,如果是障碍物,则默认初始值0
if (!i && !j) f[i][j] = 1;
else {
if (i) f[i][j] += f[i - 1][j];
if (j) f[i][j] += f[i][j - 1];
}
}
}
}
return f[n - 1][m - 1];
}
};