Minimum-Step Right-Down Grid Path
Problem statement
In a binary grid, 1 is passable and 0 is blocked. Starting at the top-left, reach the bottom-right using only one-cell Right or Down moves. Return the minimum number of moves, or -1 if unreachable.
Function
minimumRightDownSteps(grid: int[][]) → intExamples
Example 1
grid = [[1,0,1],[1,1,1],[0,1,1]]return = 4A path uses two down and two right moves.
Constraints
- The rectangular grid has at most
10^6cells.