dsa · medium
Unique Paths II
A robot starts at the top-left of obstacleGrid and may only move right or down. Cells with 1 are blocked. Return how many paths reach the bottom-right. If start or end is blocked, the answer is 0.
Arguments
obstacle_grid— m×n grid; 1 is blocked, 0 is open
Example
[[0,0,0],[0,1,0],[0,0,0]] has one blocked cell in the middle. There are 2 paths around it.
Constraints
1 <= m, n <= 100 obstacleGrid[i][j] is 0 or 1 Hidden tests include near-max size for this bound; a slower-than-intended solution TLEs.
Examples
Example 1
Input: [[0,0,0],[0,1,0],[0,0,0]] Expected: 2
Example 2
Input: [[0,1],[0,0]] Expected: 1