public int uniquePathsWithObstacles(int[][] obstacleGrid) {
        if (obstacleGrid == null || obstacleGrid.length == 0) return 0;
        int row = obstacleGrid.length, col = obstacleGrid[0].length;
        int hash[][] = new int[row][col];
        for (int i = 0; i < col; i++) {
            if (obstacleGrid[0][i] == 1) {
                break;
            }
            hash[0][i] = 1;
        }
        for (int i = 0; i < row; i++) {
            if (obstacleGrid[i][0] == 1) {
                break;
            }
            hash[i][0] = 1;
        }
        for (int x = 1; x < row; x++) {
            for (int y = 1; y < col; y++) {
                if (obstacleGrid[x][y] == 0) {
                    hash[x][y] = hash[x - 1][y] + hash[x][y - 1];
                } else {
                    hash[x][y] = 0;
                }
            }
        }
        return hash[row - 1][col - 1];
    }