Simple C++ Code || DP || Both Recursive and Iterative Approach
Recursive Approach\n\nclass Solution {\npublic:\n    vector<vector<int>> dp;\n    int fun(int x, int y, vector<vector<int>>& grid){\n        if(grid[x][y]==1) r
Recursive Approach\n```\nclass Solution {\npublic:\n    vector<vector<int>> dp;\n    int fun(int x, int y, vector<vector<int>>& grid){\n        if(grid[x][y]==1) return 0;\n        if(x==0 && y==0) return 1;\n        if(dp[x][y]!=-1) return dp[x][y];\n        int ans = 0;\n        if(x>0) ans += fun(x-1, y, grid);\n        if(y>0) ans += fun(x, y-1, grid);\n        return dp[x][y] = ans;\n    }\n    int uniquePathsWithObstacles(vector<vector<int>>& grid) {\n        int m = grid.size(), n = grid[0].size();   \n        dp.resize(m, vector<int>(n, -1));\n        return fun(m-1, n-1, grid);\n    }\n};\n```\n\nIterative Approach\n```\nclass Solution {\npublic:\n    int uniquePathsWithObstacles(vector<vector<int>>& grid) {\n        if(grid[0][0]==1) return 0;\n        int m = grid.size(), n = grid[0].size();   \n        vector<vector<int>> dp(m, vector<int>(n));\n        dp[0][0] = 1;\n        for(int i=0;i<m;i++){\n            for(int j=0;j<n;j++){\n                if(i==0 && j==0) continue;\n                dp[i][j] = 0;\n                if(grid[i][j]==1) continue;\n                if(i>0) dp[i][j] += dp[i-1][j];\n                if(j>0) dp[i][j] += dp[i][j-1];\n            }\n        }\n        return dp[m-1][n-1];\n    }\n};\n```
['Dynamic Programming', 'Depth-First Search', 'Recursion', 'Memoization', 'C', 'Iterator', 'C++']