C++ || DP (iterative) || Day 12
Code\n\nclass Solution {\npublic:\n    int uniquePathsWithObstacles(vector<vector<int>>& v) {\n        int n = v.size(),m =v[0].size();\n        if(v[0][0] || v
# Code\n```\nclass Solution {\npublic:\n    int uniquePathsWithObstacles(vector<vector<int>>& v) {\n        int n = v.size(),m =v[0].size();\n        if(v[0][0] || v[n-1][m-1])return 0;\n        vector<vector<int>>dp(n,vector<int>(m,0));\n        dp[0][0]=1;\n        for(int i=1;i<n;i++){\n            if(v[i][0])dp[i][0]=0;\n            else dp[i][0]=dp[i-1][0];\n        }\n        for(int i=1;i<m;i++){\n            if(v[0][i])dp[0][i]=0;\n            else dp[0][i]=dp[0][i-1];\n        }\n        for(int i=1;i<n;i++){\n            for(int j=1;j<m;j++){\n                if(!v[i][j])dp[i][j]=dp[i-1][j]+dp[i][j-1];\n            }\n        }\n        return dp[n-1][m-1];\n    }\n};\n```\n![upvote (2).jpg](https://assets.leetcode.com/users/images/c2e14538-66fb-4295-9705-0184793a06e1_1691815281.1305342.jpeg)\n
['Array', 'Dynamic Programming', 'Matrix', 'C++']