class Solution {
public:
int uniquePathsWithObstacles(vector<vector<int>>& obstacleGrid) {
vector<vector<int>>
dp(obstacleGrid.size() , vector<int>(obstacleGrid[0].size() , 0));
for(int i=0 ; i<obstacleGrid.size() ; i++)
{
for(int j=0 ; j<obstacleGrid[0].size() ;j++)
{
if(obstacleGrid[i][j] == 1) continue; //遇到障碍物绕开
if(i==0 && j==0) dp[0][0] = 1; //起始点
else if(i==0) dp[i][j] = dp[i][j-1]; //最边行
else if(j==0) dp[i][j] = dp[i-1][j]; //最边列
else dp[i][j] = dp[i-1][j] + dp[i][j-1];
}
}
return dp[obstacleGrid.size()-1][obstacleGrid[0].size()-1];
}
};