分析
将有障碍的地方路径设置为0即可
class Solution {
public:
int uniquePathsWithObstacles(vector<vector<int>>& obstacleGrid) {
int m=obstacleGrid.size(),n=obstacleGrid[0].size();
int f[m][n];
memset(f,0,sizeof f);
for(int i=0;i<m&&obstacleGrid[i][0]==0;i++)f[i][0]=1;
for(int i=0;i<n&&obstacleGrid[0][i]==0;i++)f[0][i]=1;
for(int i=1;i<m;i++)
for(int j=1;j<n;j++)
if(obstacleGrid[i][j]==0)
f[i][j]=f[i-1][j]+f[i][j-1];
return f[m-1][n-1];
}
};