Minimum Moves with k-Cell Jumps

Asked at Microsoft· Onsite

Reported by the problem's creator, not verified

Import another question

You are given a grid of 0 and 1 values. A cell with 0 is open; a cell with 1 is blocked. Rows are indexed 0 through m - 1 top to bottom and columns 0 through n - 1 left to right, where m and n are the grid's dimensions.

Examples

  1. Example 1

    Input: grid = [[0,0,0],[0,1,0],[0,0,0]], sr = 0, sc = 0, tr = 2, tc = 2, k = 2

    Output: 2

    Explanation: Jump right two cells from (0, 0) to (0, 2), passing the open cell (0, 1), then jump down two cells to (2, 2), passing the open cell (1, 2). Two moves suffice, and no one-move jump reaches the target.

Import your own questions
Paste a question you were asked and get a full problem: statement, tests and a checked solution.
Import a question

Code

Loading editor…

Ln 1, Col 1

Start an attempt to use Coach.