Problem · Graph
Minimum Grid Moves
Learn this problemProblem statement
In a zero-and-one maze, move from the top-left cell to the bottom-right. A move travels between 1 and k cells horizontally or vertically, but it cannot cross or land on an obstacle. Return the minimum number of moves, or -1 if the destination is unreachable.
Function
getMinimumMoves(maze: int[][], k: int) → intExamples
Example 1
maze = [[0,0],[1,0]]k = 2return = 2Move right once and down once; the obstacle blocks the other route.
Constraints
1 <= rows, columns, k <= 100- Cells contain only
0or1.