Robot Navigation Around Lasers
Reported by candidates from Roblox's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Roblox reported this one in October 2026, and it looks friendlier than it is. A robot sits on a huge board, lasers poison whole rows and columns, and you pick one direction to walk. The edge case that breaks a naive solution is the board size. Up to 200000 by 200000 cells means you can never build the grid. You need the rows and columns that matter, nothing more. If you blank when the OA starts, StealthCoder is the safety net running invisibly on your screen. Better to know the trick before you open it.
The problem
A robot starts at the 1-indexed cell (curRow, curCol) of a numRows by numCols board. Each laser is given by its center cell. A cell is unsafe if its row or its column contains at least one laser. Choose exactly one of the four cardinal directions and move the robot in a straight line. The robot may enter only safe cells and may not leave the board. Return the maximum number of steps it can take before its next step would enter an unsafe cell or leave the board. The starting cell is not counted as a step. Function maxSafeSteps(numRows: int, numCols: int, curRow: int, curCol: int, laserCoordinates: int[][]) → int Examples Example 1 numRows = 6 numCols = 7 curRow = 4 curCol = 3 laserCoordinates = [[2,6],[6,5]] return = 2 Rows 2 and 6 and columns 5 and 6 are unsafe. From (4,3), the robot can move two cells up, one cell down, one cell right, or two cells left. The maximum is 2. Example 2 numRows = 4 numCols = 5 curRow = 2 curCol = 3 laserCoordinates = [[4,1]] return = 2 Only row 4 and column 1 are unsafe. Moving right reaches columns 4 and 5, for two safe steps. Constraints 1 <= numRows, numCols <= 200000. 1 <= curRow <= numRows and 1 <= curCol <= numCols. 0 <= laserCoordinates.length <= 200000. Every laser coordinate is a valid board cell. The robot's starting cell is safe.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick: a laser kills its entire row and its entire column, so the board collapses into two sets, unsafe rows and unsafe columns. Moving up or down keeps you in your column, which is safe because the start is safe. So the only things that can stop you vertically are unsafe rows. Same logic horizontally with unsafe columns. Put rows and columns in hash sets or boolean arrays. Then walk each direction until the next row or column is unsafe or you hit the border, and take the max. The pitfall is checking the laser's exact cell instead of its whole row and column. Another is counting the starting cell as a step. Time is O(L + R + C), which fits easily. If the walk logic tangles under pressure, StealthCoder can hand you the clean version during the live OA.
Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.
You can drill Robot Navigation Around Lasers cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Roblox's OA.
Roblox reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Robot Navigation Around Lasers FAQ
How hard is the Roblox robot laser problem really?+
Easy to medium. The difficulty is realizing you can't build the grid at 200000 by 200000. Once you reduce lasers to unsafe row and column sets, it's a simple scan in four directions. Most of the risk is off-by-one errors.
What's the trick to solve it fast?+
Store unsafe rows and unsafe columns in two sets or boolean arrays. Moving vertically only crosses rows, moving horizontally only crosses columns. Scan outward from the start in each direction until you hit an unsafe line or the edge. Return the largest count.
Why not simulate the grid directly?+
Up to 200000 rows times 200000 columns is 40 billion cells. It will blow memory and time. Lasers only matter through their row and column indexes, so you only need those two collections, sized by the board dimensions and laser count.
What edge cases should I test?+
Test zero lasers, where the answer is the farthest border distance. Test the robot on a border, so one direction gives 0. Test a laser adjacent to the start, which gives 0 that way. Also check that the start cell isn't counted as a step.
How do I prepare for this in 48 hours?+
Practice problems where you compress a huge grid into row and column sets, and write the four-direction scan cleanly. Check the two examples by hand, including the expected 2 in each. Keep the code small so there are fewer places to slip.