Python easy solutions
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\nSame as unique path solution. But we do just one thing that, where the ob
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nSame as unique path solution. But we do just one thing that, where the obstacle is there we assign it to zero and calculate further. \n\n# Complexity\n- Time complexity:\nO(m*n)\n\n- Space complexity:\nO(n)\n\n# Code\n```\nclass Solution:\n    def uniquePathsWithObstacles(self, obstacleGrid: List[List[int]]) -> int:\n        # m, n = len(obstacleGrid), len(obstacleGrid[0])\n        # dp = {(m-1, n-1): 1}\n\n        # def dfs(r, c):\n        #     if r==m or c==n or obstacleGrid[r][c]:\n        #         return 0\n        #     if (r, c) in dp:\n        #         return dp[(r, c)]\n        #     dp[(r, c)] = dfs(r+1, c) + dfs(r, c+1)\n        #     return dp[(r, c)]\n        # return dfs(0, 0)\n        m, n = len(obstacleGrid), len(obstacleGrid[0])\n       \n        if obstacleGrid[m-1][n-1] == 1: \n            return 0\n        else:\n            dp = [0]*n\n            dp[n-1] = 1\n\n            for i in reversed(range(m)):\n                for j in reversed(range(n)):\n                    if obstacleGrid[i][j]:\n                        dp[j] = 0\n                    elif j+1 < n:\n                        dp[j] = dp[j] + dp[j+1]\n\n        return dp[0]\n```
['Array', 'Dynamic Programming', 'Matrix', 'Python3']