Company: REVOLUT
Difficulty: medium
Minimum Moves In a grid-based maze, each cell is either empty ( 0 ) or contains an obstacle ( 1 ). HackerMan starts at cell (0, 0) and must navigate to cell (n-1, m-1) of an n x m maze. He is given a jump parameter k , which allows these moves: Right: (i, j) -> (i, j+x) where 1 <= x <= k Down: (i, j) -> (i+x, j) where 1 <= x <= k Left: (i, j) -> (i, j-x) where 1 <= x <= k Up: (i, j) -> (i-x, j) where 1 <= x <= k For any move, all cells in the path must be obstacle-free and within the maze boundaries. That is, a move from (i, j) to a cell x steps away passes through every intermediate cell, and each of those cells (as well as the destination cell) must be empty. Determine the minimum number of moves required to reach the destination, or report -1 if it is impossible. Input Format The first line contains an integer, n , denoting the number of rows in the maze. The second line contains an integer, m , denoting the number of columns in the maze. Each of