FastPrepMinimum Moves
Problems/Minimum Moves

Minimum Moves

Airbnb logoAirbnb● MediumINTERNOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

There is a maze in HackerPlay where children play for recreation.

The maze is represented as an n * m grid of cells, where each cell is either empty (denoted by 0), or contains an obstacle (denoted by 1). HackerMan is currently standing at cell (0, 0) and wishes to reach the cell (n - 1, m - 1).

For a jump parameter denoted by k, in one move, HackerMan can move to any of the following cells:

  • (i + x, j) where 1 ≤ x ≤ k provided cell (i + x, j) lies in the maze and there are no cells containing obstacles in the range (i, j) → (i + 1, j) → ... → (i + x, j).
  • (i - x, j) where 1 ≤ x ≤ k provided cell (i - x, j) lies in the maze and there are no cells containing obstacles in the range (i, j) → (i - 1, j) → ... → (i - x, j).
  • (i, j + x) where 1 ≤ x ≤ k provided cell (i, j + x) lies in the maze and there are no cells containing obstacles in the range (i, j) → (i, j + 1) → ... → (i, j + x).
  • (i, j - x) where 1 ≤ x ≤ k provided cell (i, j - x) lies in the maze and there are no cells containing obstacles in the range (i, j) → (i, j - 1) → ... → (i, j - x).

Find the minimum number of moves in which HackerMan can reach the cell (n - 1, m - 1) starting from (0, 0), or -1 if it is impossible to reach that cell.

Complete the function getMinimumMoves in the editor below.

getMinimumMoves has the following parameters:

  1. int maze[n][m]: the maze in HackerPlay where HackerMan is standing
  2. int k: the maximum distance HackerMan can traverse in one move

int: the minimum number of moves in which HackerMan can reach the destination cell (n - 1, m - 1)

  • 1 ≤ n ≤ 100
  • 1 ≤ m ≤ 100
  • 1 ≤ k ≤ 100
  • Each cell of the grid contains values either 0 or 1.

Function

getMinimumMoves(maze: int[][], k: int) → int

Examples

Example 1

maze = [[0, 0], [1, 0]]k = 2return = 2
maze
01000110

The maze looks like this.

0 0 1 0

The following sequence of moves can be performed: (0, 0) → (0, 1) → (1, 1). Hence, HackerMan can reach the end in 2 moves, which is minimum possible. The answer is 2.

Example 2

maze = [[0, 0, 0], [1, 0, 0]]k = 5return = 2
maze
01200001100

The maze can be represented as:

0 0 0 1 0 0

The following sequence of moves can be performed: (0, 0) → (0, 2) → (1, 2).

Constraints

  • 1 ≤ n ≤ 100
  • 1 ≤ m ≤ 100
  • 1 ≤ k ≤ 100
  • maze[i][j] is 0 (empty) or 1 (obstacle).

More Airbnb interview questions

  • Bouncing DiagonalsOA · Seen Dec 2026
  • Count Numbers Not Equal to the First TwoOA · Seen Dec 2026
  • Garden Sprinkler PlacementOA · Seen Dec 2026
  • Theme Park Shuttle Wait TimeOA · Seen Dec 2026
  • Merge Event PreferencesPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Run-Length Encoding and DecodingPHONE SCREEN · Seen Nov 2026
  • Count Card Duel RoundsOA · Seen Nov 2026
  • Count Lamps Lighting Each PointOA · Seen Nov 2026
  • Simulate Orchard Rot SpreadOA · Seen Nov 2026
  • Sort Adjacent PairsOA · Seen Nov 2026

Similar questions at other companies

  • Simulate Orchard Rot SpreadCapital One · OACapital One interview questions
  • Shortest Path in a Binary MatrixGoogle · OAGoogle interview questions
  • Minimize CommuteDatabricks · OA · PHONE SCREENDatabricks interview questions
  • Minimum MovesHarness · OA
  • Shortest Atom Action PathOpenAI · OAOpenAI interview questions
  • Minimum Cleaning Robot RunsHSBC · OAHSBC interview questions
  • Shortest Path Around Rectangular ObstaclesDRW · OADRW interview questions
  • Rotten Oranges / Grid Infection BFSLyft · OALyft interview questions
  • Count Islands with DFS and BFSVisa · OAVisa interview questions
  • Closest DashMartDoorDash · OA · PHONE SCREENDoorDash interview questions

Interview reports that mention this question

  • Airbnb Intern OA, Donut Challenge: 22 Experiences (Part 2 of 7)

Airbnb interview experiences

  • Airbnb OA · November 2026
  • Airbnb Campus and Full-Time SWE OA / Interviews: 9 Experiences
  • Airbnb Intern Phone Interviews: 21 Experiences (Part 7 of 7)
  • Airbnb Intern OA and Phone Screens: 17 Experiences (Part 6 of 7)
  • Airbnb Intern OA and Onsite Rounds: 16 Experiences (Part 5 of 7)
All Airbnb interview questionsSee Airbnb hiring insights
Saved
class Solution {
    public int getMinimumMoves(int[][] maze, int k) {
      // write your code here
    }

}
Checking account…