Unique paths II
Standard · Write code · about 12 min
A robot starts in the top-left cell of obstacleGrid and moves only right or down to the bottom-right cell. Cells holding 1 are obstacles the robot cannot enter; cells holding 0 are open.
Return the number of different paths.
Example 1
Input:
[[[0,0,0],[0,1,0],[0,0,0]]]
Output:
2
Example 2
Input:
[[[0,1],[0,0]]]
Output:
1
Only down, then right.
Constraints
- 1 ≤ rows, cols ≤ 100
- obstacleGrid[r][c] is 0 or 1
- The answer fits in a 32-bit signed integer
Learn the idea first: Grid DP: paths, minimum path sum, obstacles, a visual lesson.
More Grid DP: paths, minimum path sum, obstacles problems
- Unique paths Warm-up
- Fill the paths table Warm-up
- Minimum path sum Standard
- Triangle Standard
- Dungeon game Challenge