Navigate a Binary Grid with Obstacle Jumps
Updated
Problem statement
A rectangular binary grid contains walkable cells 1 and blocked cells 0. Determine whether you can travel from the top-left cell to the bottom-right cell.
You may move up, down, left, or right in either of these ways:
- Step one cell onto a
1. - Jump two cells over a
0and land on a1.
Both the intermediate and landing cells must lie inside the grid. Diagonal moves and jumps over a 1 are not allowed.
For this exercise, assume jumps may be repeated any number of times and do not change the grid. There is no obstacle-removal budget. If either endpoint is blocked, return false. A single walkable cell is already reachable. Return true exactly when some sequence of legal moves reaches the bottom-right cell.
Function
canNavigateGrid(grid: int[][]) → booleanExamples
Example 1
grid = [[1,0,1],[0,0,0],[1,0,1]]return = trueJump right over the top-middle obstacle, then down over the middle-right obstacle.
Example 2
grid = [[1,0,0,1]]return = falseTwo consecutive blocked cells cannot be crossed by a jump over exactly one obstacle.
Example 3
grid = [[1]]return = trueThe start is already the destination.
Constraints
1 <= grid.length, grid[0].length <= 30.- Every row has the same length and every entry is
0or1.
More Roblox Onsite Interview questions
- Most Frequent Call Path From Function Trace LogsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Design Search Autocomplete SystemPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Candy Crush Grid Matching and GravityPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Topological Sort with Secondary OrderingPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Most Frequent Call Stack Per ThreadPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Count and Score Distinct Hat AssignmentsONSITE INTERVIEW · Seen Sep 2026
- Rate Limiter Sliding Window With Per-Entity LimitsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
- Most Frequent Call Path in Interleaved LogsONSITE INTERVIEW · Seen Aug 2026
- Grid Pathfinding with Obstacles (DFS)PHONE SCREEN · ONSITE INTERVIEW · Seen Jun 2026
- Maximize Distance to Closest Person — Return the SeatONSITE INTERVIEW · Seen Jun 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
- Mouse and Cheese ReachabilityMeta · ONSITE INTERVIEWMeta interview questions
- Number of IslandsTripjack · ONSITE INTERVIEWTripjack interview questions
- Number of IslandsTekion · ONSITE INTERVIEWTekion interview questions
- Number of IslandsGoldman Sachs · OA · PHONE SCREEN · ONSITE INTERVIEWGoldman Sachs interview questions