human
I found an interesting problem on https://leetcode.com/problems/unique-paths-ii/:
A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).

The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below).

Now consider if some obstacles are added to the grids. How many unique paths would there be?


An obstacle and empty space is marked as 1 and 0 respectively in the grid.

Note: m and n will be at most 100.

Example 1:

Input:
[
  [0,0,0],
  [0,1,0],
  [0,0,0]
]
Output: 2
Explanation:
There is one obstacle in the middle of the 3x3 grid above.
There are two ways to reach the bottom-right corner:
1. Right -> Right -> Down -> Down
2. Down -> Down -> Right -> Right

I tried it in Python, but could not do it. Can you solve it?

 Can you provide a the Python program you requested?
assistant
#Here is the Python program you requested.

class Solution:
     def uniquePathsWithObstacles(self, obstacleGrid):
         """
         :type obstacleGrid: List[List[int]]
         :rtype: int
         """
         m = len(obstacleGrid)
         n = len(obstacleGrid[0])
         mat = [[0] * n for _ in range(m)]
         if not obstacleGrid[0][0]:
             mat[0][0] = 1
         for row in range(m):
             for col in range(n):
                 if col == 0 and row == 0:
                     mat[row][col] = obstacleGrid[row][col] * -1 + 1
                 elif obstacleGrid[row][col] == 1:
                     mat[row][col] == 0
                 else:
                     mat[row][col] = mat[row - 1][col] + mat[row][col - 1]
         return mat[m - 1][n - 1]