✅  Python Easy DP 2 approaches- Beats ~99%
The code is using a DP array to solve the problem. The two approaches listed below varies on Space complexity. Both the approaches take O(mn)  time.\n1. ##### S
The code is using a DP array to solve the problem. The two approaches listed below varies on Space complexity. Both the approaches take **O(m*n)**  time.\n1. ##### **Space O(m*n)**\n\nThe extra space is for the `DP` array.\n\n```\nclass Solution:\n    def uniquePathsWithObstacles(self, obstacleGrid: List[List[int]]) -> int:              \n        m, n = len(obstacleGrid), len(obstacleGrid[0])        \n        \n        dp=[[0] * (n+1) for _ in range(m+1)]        \n        dp[0][1]=1\n                        \n        for row in range(1, m+1):\n            for col in range(1, n+1):\n                if not obstacleGrid[row-1][col-1]:\n                    dp[row][col] = dp[row-1][col] + dp[row][col-1]\n         \n        return dp[-1][-1]\n```\n\n2.  ##### **Space O(1)**\n\nHere the code will be using the input array as the DP array. In most cases, mutating the input is not recommended. It creates [side-effects](https://en.wikipedia.org/wiki/Side_effect_(computer_science)) in your code. But this approach is a fun exercise on exploring other alternative solutions within the given problem constraints.\n\n```\nclass Solution:\n    def uniquePathsWithObstacles(self, obstacleGrid: List[List[int]]) -> int:              \n        if obstacleGrid[0][0] == 1:\n            return 0\n        \n        m, n = len(obstacleGrid), len(obstacleGrid[0])        \n        \n        obstacleGrid[0][0] = 1\n        for i in range(1,m):\n            obstacleGrid[i][0] = 1 if obstacleGrid[i][0] == 0 and obstacleGrid[i-1][0] == 1 else 0\n        \n        for i in range(1,n):\n            obstacleGrid[0][i] = 1 if obstacleGrid[0][i] == 0 and obstacleGrid[0][i-1] == 1 else 0\n            \n        \n        for row in range(1, m):\n            for col in range(1, n):                \n                obstacleGrid[row][col] = obstacleGrid[row-1][col] + obstacleGrid[row][col-1] if obstacleGrid[row][col] == 0 else 0\n         \n        return obstacleGrid[-1][-1]\n```\n\n\n---\n\n***Please upvote if you find it useful***
['Python', 'Python3']