FastPrepRolling-Ball Maze Reachability
Problems/Rolling-Ball Maze Reachability

Rolling-Ball Maze Reachability

Meta logoMeta● MediumFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The Meta onsite report names a well-known maze problem with a rolling ball but does not give its statement. This reachability exercise is our own reading of that reference. The detailed rules, limits and examples are ours, not from the report.

A ball starts at start in a rectangular maze. Cells marked 0 are open and cells marked 1 are walls. Choose one of the four cardinal directions. The ball continues rolling through open cells in that direction until the next step would hit a wall or leave the maze; only then can it choose another direction.

Return true if some sequence of rolls lets the ball stop at destination, and false otherwise. Passing through the destination without stopping does not count. The starting cell is already a stopping position, so equal start and destination coordinates return true.

Function

hasPath(maze: int[][], start: int[], destination: int[]) → boolean

Examples

Example 1

maze = [[0,0,0],[1,1,0],[0,0,0]]start = [0,0]destination = [2,0]return = true
maze
012000011102000

Roll right to (0,2), down to (2,2), then left to (2,0). Each turn happens at a stopping cell.

Example 2

maze = [[0,0,0]]start = [0,0]destination = [0,1]return = false
maze
0120000

The only horizontal roll from (0,0) stops at (0,2). The ball passes (0,1) but cannot stop there.

Example 3

maze = [[0]]start = [0,0]destination = [0,0]return = true
maze
000

The ball is already stopped at the destination before making any roll.

Constraints

  • 1 <= maze.length, maze[0].length <= 100; the maze is rectangular.
  • Every cell is 0 or 1.
  • start and destination are two-element, zero-based [row,column] coordinates inside the maze, and both name open cells.

More Meta Onsite Interview questions

  • Multi-Head Attention Forward PassPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Run-Length Encoded Vector Dot ProductPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Mutual-Friend RecommendationsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Deterministic K-Means AssignmentsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Linear Layer Forward and Backward PassesONSITE INTERVIEW · Seen Sep 2026
  • Reservoir Sampling with Recorded DrawsONSITE INTERVIEW · Seen Sep 2026
  • Stochastic Gradient Descent with MomentumONSITE INTERVIEW · Seen Sep 2026
  • Top K Largest Values with a HeapONSITE INTERVIEW · Seen Sep 2026
  • Partition a Card Deck into FifteensONSITE INTERVIEW · Seen Sep 2026
  • Insert into a Sorted Circular ListONSITE INTERVIEW · Seen Aug 2026

Similar questions at other companies

  • Number of IslandsAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Explore an Unknown Grid and Find a PathLinkedIn · ONSITE INTERVIEWLinkedIn interview questions
  • Nearest Charging Station on a GridSpotify · ONSITE INTERVIEW
  • Number of Islands with Diagonal ConnectivityGoogle · ONSITE INTERVIEWGoogle interview questions
  • Island Count and Maximum AreaOracle · ONSITE INTERVIEWOracle interview questions
  • Shortest Increasing Path to a TargetUber · ONSITE INTERVIEWUber interview questions
  • Number of IslandsTripjack · ONSITE INTERVIEWTripjack interview questions
  • Number of IslandsTekion · ONSITE INTERVIEWTekion interview questions
  • Grid Pathfinding with Obstacles (DFS)Roblox · PHONE SCREEN · ONSITE INTERVIEWRoblox interview questions
  • Number of IslandsGoldman Sachs · OA · PHONE SCREEN · ONSITE INTERVIEWGoldman Sachs interview questions

Meta interview experiences

  • Meta PhD SWE Intern AI Coding Phone Screen: 1 Experience
  • Meta Business Support Engineer Phone Screen: 1 Experience
  • Meta Software Engineer Onsite Questions: 3 Experiences
  • Meta AI Native Engineer OA and Onsite: 1 Experience
  • Meta AI-Native Coding Interview: 3 Experiences
  • Meta Production Engineer Intern Questions: 6 Experiences
All Meta interview questionsSee Meta hiring insights
Saved
class Solution {
    public boolean hasPath(int[][] maze, int[] start, int[] destination) {
        // Write your code here.
    }
}
Checking account…