Python different solutions (O(m*n), O(n), in place).
    \n    # O(m*n) space\n    def uniquePathsWithObstacles1(self, obstacleGrid):\n        if not obstacleGrid:\n            return \n        r, c = len(obstacle
        \n    # O(m*n) space\n    def uniquePathsWithObstacles1(self, obstacleGrid):\n        if not obstacleGrid:\n            return \n        r, c = len(obstacleGrid), len(obstacleGrid[0])\n        dp = [[0 for _ in xrange(c)] for _ in xrange(r)]\n        dp[0][0] = 1 - obstacleGrid[0][0]\n        for i in xrange(1, r):\n            dp[i][0] = dp[i-1][0] * (1 - obstacleGrid[i][0])\n        for i in xrange(1, c):\n            dp[0][i] = dp[0][i-1] * (1 - obstacleGrid[0][i])\n        for i in xrange(1, r):\n            for j in xrange(1, c):\n                dp[i][j] = (dp[i][j-1] + dp[i-1][j]) * (1 - obstacleGrid[i][j])\n        return dp[-1][-1]\n        \n    # O(n) space\n    def uniquePathsWithObstacles2(self, obstacleGrid):\n        if not obstacleGrid:\n            return \n        r, c = len(obstacleGrid), len(obstacleGrid[0])\n        cur = [0] * c\n        cur[0] = 1 - obstacleGrid[0][0]\n        for i in xrange(1, c):\n            cur[i] = cur[i-1] * (1 - obstacleGrid[0][i])\n        for i in xrange(1, r):\n            cur[0] *= (1 - obstacleGrid[i][0])\n            for j in xrange(1, c):\n                cur[j] = (cur[j-1] + cur[j]) * (1 - obstacleGrid[i][j])\n        return cur[-1]\n    \n    # in place\n    def uniquePathsWithObstacles(self, obstacleGrid):\n        if not obstacleGrid:\n            return \n        r, c = len(obstacleGrid), len(obstacleGrid[0])\n        obstacleGrid[0][0] = 1 - obstacleGrid[0][0]\n        for i in xrange(1, r):\n            obstacleGrid[i][0] = obstacleGrid[i-1][0] * (1 - obstacleGrid[i][0])\n        for i in xrange(1, c):\n            obstacleGrid[0][i] = obstacleGrid[0][i-1] * (1 - obstacleGrid[0][i])\n        for i in xrange(1, r):\n            for j in xrange(1, c):\n                obstacleGrid[i][j] = (obstacleGrid[i-1][j] + obstacleGrid[i][j-1]) * (1 - obstacleGrid[i][j])\n        return obstacleGrid[-1][-1]
['Dynamic Programming', 'Python']