FastPrepRobot Shortest Walkable Path
Problems/Robot Shortest Walkable Path

Robot Shortest Walkable Path

Roblox logoRoblox● MediumNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A campus-hiring candidate reports a robot that moves up, down, left, and right through cells marked 1, avoids cells marked 0, and asks for the length of the shortest path. We chose the limits, zero-based coordinates, and what to return when the end is unreachable or blocked. Our version is about 90% the same as the reported question.

You control a robot in a rectangular binary grid. A cell containing 1 is walkable and a cell containing 0 is an obstacle. In one move, the robot may go up, down, left or right to a neighboring walkable cell inside the grid. Obstacles cannot be crossed or removed.

Return the minimum number of moves from start to target. For this exercise, assume each coordinate is a zero-based [row,column] pair. Return -1 when either endpoint is blocked or no path exists; return 0 when both coordinates name the same walkable cell. Keep all inputs unchanged.

Function

shortestPath(grid: int[][], start: int[], target: int[]) → int

Examples

Example 1

grid = [[1,0,1],[1,1,1]]start = [0,0]target = [0,2]return = 4
grid
01201011111

Walk down, right, right and up; the obstacle prevents a shorter route.

Example 2

grid = [[1,0],[0,1]]start = [0,0]target = [1,1]return = -1
grid
01010101

The two walkable cells touch only diagonally.

Example 3

grid = [[1]]start = [0,0]target = [0,0]return = 0
grid
001

The robot is already at the walkable target.

Constraints

  • The grid has 1..50 rows and 1..50 columns.
  • Every cell is 0 or 1.
  • start and target each contain two in-bounds coordinates.

More Roblox Phone Screen questions

  • Design Search Autocomplete SystemPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Most Frequent Call Path From Function Trace LogsPHONE SCREEN · Seen Nov 2026
  • Candy Crush Grid Matching and GravityPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Implement a Rate LimiterPHONE SCREEN · Seen Oct 2026
  • Rate Limit by Multiple Request FieldsPHONE SCREEN · Seen Oct 2026
  • Topological Sort with Secondary OrderingPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Time-Aware Search AutocompletePHONE SCREEN · Seen Oct 2026
  • Most Frequent Call Stack Per ThreadPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Rate Limiter Sliding Window With Per-Entity LimitsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Closest Binary Search Tree Value — Base PracticePHONE SCREEN · Seen Jun 2026

Similar questions at other companies

  • Minimum Time to Spread Through a GridAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Max Area of Island Without Changing the GridFlexport · PHONE SCREENFlexport interview questions
  • Process Minesweeper Game OperationsAmperity · PHONE SCREENAmperity interview questions
  • Count Islands in a Binary GridApple · PHONE SCREENApple interview questions
  • Find and Reconstruct a Binary-Matrix PathMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
  • Pacific Atlantic Water FlowAnduril · PHONE SCREENAnduril interview questions
  • Fuel-Aware Grid ReachabilityBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • House Bounds in a Ragged GridRippling · OA · PHONE SCREENRippling interview questions
  • Nearest Reachable Grid CornerSplunk · PHONE SCREENSplunk interview questions
  • Rotting Orange PropagationIndeed · PHONE SCREENIndeed interview questions

Interview reports that mention this question

  • Roblox New Grad Engineer Rounds: 13 Experiences (Part 6 of 7)

Roblox interview experiences

  • Roblox New Grad Early OA Tasks: 10 Experiences (Part 7 of 7)
  • Roblox New Grad HackerRank OA: 18 Experiences (Part 5 of 7)
  • Roblox New Grad CodeSignal Finals: 23 Experiences (Part 4 of 7)
  • Roblox New Grad Games and BQ: 25 Experiences (Part 3 of 7)
  • Roblox New Grad Coding Rounds: 23 Experiences (Part 2 of 7)
All Roblox interview questionsSee Roblox hiring insights
Saved
class Solution {
    public int shortestPath(int[][] grid, int[] start, int[] target) {
        // write your code here
    }

}
Checking account…