public int uniquePathsWithObstacles(int[][] obstacleGrid) {
        int m = obstacleGrid.length;
        if(m == 0) return 0;
        int n = obstacleGrid[0].length;

        int[][] memo = new int [m][n];
        for(int i = 0; i < m; i++){
            for(int j = 0; j < n; j++){
                memo[i][j] = -1;
            }
        }
        memo[0][0] = 1;
        return uniquePaths(obstacleGrid, m - 1, n - 1, memo);
    }