1 public class Solution {
2 public int uniquePathsWithObstacles(int[][] obstacleGrid) {
3 // IMPORTANT: Please reset any member data you declared, as
4 // the same Solution instance will be reused for each test case.
5 int m = obstacleGrid.length;
6 int n = obstacleGrid[0].length;
7 int[][] mytable = new int[m][n];
8
9 for(int i = 0; i < m; i++)
10 for(int j = 0; j < n; j++){
11 if(obstacleGrid[i][j] == 1)
12 continue;
13 else if(i - 1 < 0 && j - 1 < 0)
14 mytable[0][0] = 1;
15 else if(i - 1 < 0)
16 mytable[i][j] = mytable[i][j - 1];
17 else if(j - 1 < 0)
18 mytable[i][j] = mytable[i - 1][j];
19 else
20 mytable[i][j] = mytable[i][j - 1] + mytable[i - 1][j];
21 }
22 return mytable[m-1][n-1];
23 }
24 }