Unique Paths in a Grid Time : Space : 12345678910111213141516int Solution::uniquePathsWithObstacles(vector<vector<int> > &A) { if(A[0][0] == 1) return 0; int n = A.size(), m = A[0].size(); if(A[n-1][m-1] == 1) return 0; vector<vector<int>> dp(n + 1, vector<int>(m + 1,0)); dp[0][0] = 1; for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { if(A[i][j]) continue; dp[i+1][j] += dp[i][j]; dp[i][j+1] += dp[i][j]; } } return dp[n-1][m-1];}