classSolution{public:intuniquePathsWithObstacles(vector<vector<int>>& obstacleGrid){int n = obstacleGrid.size();int m = obstacleGrid[0].size();
vector< vector<int>>dp(n,vector<int>(m,0));for(int i =0; i < m && obstacleGrid[0][i]==0; i++){
dp[0][i]=1;}for(int j =0; j < n && obstacleGrid[j][0]==0; j++){
dp[j][0]=1;}for(int j =1; j < n; j++)for(int i =1; i < m; i++){if(obstacleGrid[j][i]==0){
dp[j][i]= dp[j][i-1]+ dp[j-1][i];}}return dp[n-1][m-1];}};