Java dp solutions (O(n*n), O(n) space).
\n\n       \n    // O(nn) space\n    public int uniquePathsWithObstacles1(int[][] obstacleGrid) {\n        int row = obstacleGrid.length, col = obstacleGrid[0].
  \n\n       \n    // O(n*n) space\n    public int uniquePathsWithObstacles1(int[][] obstacleGrid) {\n        int row = obstacleGrid.length, col = obstacleGrid[0].length;\n        int dp[][] = new int[row][col];\n        dp[0][0] = 1-obstacleGrid[0][0];\n        for (int i=1; i<row; i++)\n            dp[i][0] = dp[i-1][0]*(1-obstacleGrid[i][0]);\n        for (int j=1; j<col; j++)\n            dp[0][j] = dp[0][j-1]*(1-obstacleGrid[0][j]);\n        for (int i=1; i<row; i++) \n            for (int j=1; j<col; j++)\n                dp[i][j] = (dp[i-1][j]+dp[i][j-1])*(1-obstacleGrid[i][j]);\n        return dp[row-1][col-1];\n    }\n    \n    // O(n) space\n    public int uniquePathsWithObstacles(int[][] obstacleGrid) {\n        int row = obstacleGrid.length, col = obstacleGrid[0].length;\n        int dp[] = new int[col];\n        dp[0] = 1-obstacleGrid[0][0];\n        for (int j=1; j<col; j++)\n            dp[j] = dp[j-1]*(1-obstacleGrid[0][j]);\n        for (int i=1; i<row; i++) {\n            dp[0] *= 1-obstacleGrid[i][0];\n            for (int j=1; j<col; j++) \n                dp[j] = (dp[j-1]+dp[j])*(1-obstacleGrid[i][j]);\n        }\n        return dp[col-1];\n    }
['Dynamic Programming', 'Java']