C++ || O(N*M) || DP
Connect with me on LinkedIn: https://www.linkedin.com/in/abhay5349singh/\n\n\nclass Solution {\npublic:\n    int uniquePathsWithObstacles(vector<vector<int>>& g
**Connect with me on LinkedIn**: https://www.linkedin.com/in/abhay5349singh/\n\n```\nclass Solution {\npublic:\n    int uniquePathsWithObstacles(vector<vector<int>>& grid) {\n        int n=grid.size(), m=grid[0].size();\n        \n        if(grid[0][0]==1) return 0;\n        \n        vector<vector<int>> dp(n,vector<int>(m,0));\n        \n        // 0th row: movement from left -> right\n        for(int i=0, j=0;j<m;j++){\n            if(grid[i][j]==1) break;\n            dp[i][j]=1;\n        }\n        \n        // 0th col: movement from top -> bottom\n        for(int j=0, i=0;i<n;i++){\n            if(grid[i][j]==1) break;\n            dp[i][j]=1;\n        }\n        \n        for(int i=1;i<n;i++){\n            for(int j=1;j<m;j++){\n                if(grid[i][j]==1) continue;\n                dp[i][j]=dp[i-1][j] + dp[i][j-1];\n            }\n        }\n        return dp[n-1][m-1];\n    }\n};\n```\n\n**Do upvote if it helps :)**
['C++']