Beats 100% +Video | Java C++ Python
\n\n\nclass Solution {\n    public int uniquePathsWithObstacles(int[][] A) {\n        int n = A.length;\n        int m = A[0].length;\n        int [][] ans = ne
<iframe width="560" height="315" src="https://www.youtube.com/embed/ra9n-M2OzDM" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>\n\n```\nclass Solution {\n    public int uniquePathsWithObstacles(int[][] A) {\n        int n = A.length;\n        int m = A[0].length;\n        int [][] ans = new int[n][m];\n        for(int i = 0;i<n;i++){\n            if(A[i][0] == 0) ans[i][0] = 1;\n            else break;\n        }\n        for(int j = 0;j<m;j++){\n            if(A[0][j] == 0) ans[0][j] = 1;\n            else break;\n        }\n\n        for(int i = 1;i<n;i++){\n            for(int j = 1;j<m;j++){\n                if(A[i][j]==0) ans[i][j] = ans[i-1][j]+ans[i][j-1];\n            }\n        }\n        return ans[n-1][m-1];\n    }\n}\n```\n\n```\nclass Solution {\npublic:\n    int uniquePathsWithObstacles(vector<vector<int>>& A) {\n        int n = A.size();\n        int m = A[0].size();\n        vector<vector<int>> ans(n, vector<int>(m, 0));\n        \n        for (int i = 0; i < n; i++) {\n            if (A[i][0] == 0)\n                ans[i][0] = 1;\n            else\n                break;\n        }\n        \n        for (int j = 0; j < m; j++) {\n            if (A[0][j] == 0)\n                ans[0][j] = 1;\n            else\n                break;\n        }\n        \n        for (int i = 1; i < n; i++) {\n            for (int j = 1; j < m; j++) {\n                if (A[i][j] == 0)\n                    ans[i][j] = ans[i-1][j] + ans[i][j-1];\n            }\n        }\n        \n        return ans[n-1][m-1];\n    }\n};\n\n```\n\n```\nclass Solution:\n    def uniquePathsWithObstacles(self, A: List[List[int]]) -> int:\n        n = len(A)\n        m = len(A[0])\n        ans = [[0] * m for _ in range(n)]\n        \n        for i in range(n):\n            if A[i][0] == 0:\n                ans[i][0] = 1\n            else:\n                break\n        \n        for j in range(m):\n            if A[0][j] == 0:\n                ans[0][j] = 1\n            else:\n                break\n        \n        for i in range(1, n):\n            for j in range(1, m):\n                if A[i][j] == 0:\n                    ans[i][j] = ans[i-1][j] + ans[i][j-1]\n        \n        return ans[n-1][m-1]\n\n```
['C', 'Python', 'Java']