My Accepted JAVA solution - All possible solution
Code\njava []\n// Approach -1 Memorization\nclass Solution {\n    public int uniquePathsWithObstacles(int[][] obstacleGrid) {\n\n        int n = obstacleGrid.le
# Code\n```java []\n// Approach -1 Memorization\nclass Solution {\n    public int uniquePathsWithObstacles(int[][] obstacleGrid) {\n\n        int n = obstacleGrid.length;\n        int m = obstacleGrid[0].length;\n        int [][] dp = new int [n][m];\n        for(int [] i : dp) Arrays.fill(i,-1);\n\n        return solve(n-1,m-1,obstacleGrid,dp);        \n    }\n    int solve(int n, int m, int [][] obstacleGrid, int [][]dp){\n\n        if(n>=0 && m>=0 && obstacleGrid[n][m] ==1) return 0;\n\n        if(n<0 || m<0) return 0;\n\n        if(n==0 && m==0) return 1;\n\n        if(dp[n][m]!=-1) return dp[n][m];\n\n        int l = solve(n-1,m,obstacleGrid,dp);\n        int d = solve(n,m-1,obstacleGrid,dp);\n        return dp[n][m] = l+d;\n    }\n}\n```\n```java []\n// Approach -2 Tabulation\nclass Solution {\n    public int uniquePathsWithObstacles(int[][] obstacleGrid) {\n\n        int n = obstacleGrid.length;\n        int m = obstacleGrid[0].length;\n        int [][] dp = new int [n][m];\n        \n        for(int i=0;i<n;i++){\n            for(int j=0;j<m;j++){\n\n                if(i>=0 && j>=0 && obstacleGrid[i][j]==1){\n                    dp[i][j] =0;\n                    continue;\n                }\n                if(i==0 && j ==0){\n                    dp[i][j] =1;\n                    continue;\n                }\n                int le =0;\n                int up =0;\n                if(i>0) le = dp[i-1][j];\n                if(j>0) up = dp[i][j-1];\n\n                dp[i][j]=le+up;\n            }\n        }\n        return dp[n-1][m-1];\n    }\n}\n```\n```java []\n// Approach -3 Space Optimization\nclass Solution {\n    public int uniquePathsWithObstacles(int[][] obstacleGrid) {\n\n        int n = obstacleGrid.length;\n        int m = obstacleGrid[0].length;\n        int []prev = new int[m];\n        \n        for(int i=0;i<n;i++){\n            int [] cur = new int[m];\n            \n            for(int j=0;j<m;j++){\n\n                if(i>=0 && j>=0 && obstacleGrid[i][j]==1){\n                    cur[j] =0;\n                    continue;\n                }\n                if(i==0 && j ==0){\n                    cur[j] =1;\n                    continue;\n                }\n                int le =0;\n                int up =0;\n                if(i>0) le = prev[j];\n                if(j>0) up = cur[j-1];\n\n                cur[j]=le+up;\n            }\n            prev = (int [])(cur.clone());\n        }\n        return prev[m-1];\n    }\n}\n```\n\n
['Dynamic Programming', 'Matrix', 'Java']