Imagine a robot starting at the top-left corner of an m ร n grid, trying to reach the bottom-right corner. The robot can only move right or down at each step - no diagonal moves allowed!
Here's the twist: some cells in the grid contain obstacles (marked as 1) that block the robot's path, while empty spaces are marked as 0. The robot must navigate around these obstacles.
Your mission: Calculate how many different unique paths the robot can take to reach its destination while avoiding all obstacles.
Example: In a 3ร3 grid with an obstacle in the middle, the robot might have multiple ways to reach the goal by going around the obstacle.
Input & Output
Constraints
- m == obstacleGrid.length
- n == obstacleGrid[i].length
- 1 โค m, n โค 100
- obstacleGrid[i][j] is 0 or 1
- The testcases are generated so that the answer will be less than or equal to 2 ร 109