Laser Robot Safe Path
Reported by candidates from Capital One's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Capital One reported this one in May 2026, and the name "Laser Robot Safe Path" sounds scarier than it is. Strip the story and it's a grid walk. A robot sits on a small board, lasers wipe out whole rows and columns, and you count how far it can step in each of four directions before hitting a burned cell. The board maxes out at 20 x 20 with at most 5 lasers, so brute force is the intended answer. If your head goes blank under the timer, StealthCoder is the hedge that can read the prompt and hand you the walk logic live.
The problem
A special thank-you to the friend who kindly shared that this problem was seen again on August 4, 2026! (∩˃o˂∩)♡ Imagine a board of size numRows x numColumns with lasers placed on it. Their coordinates are given in the two-dimensional array laserCoordinates, where laserCoordinates[i] is a two-element array containing the one-based row and column coordinates of the center of the ith laser. A laser centered at (row, column) destroys everything in row row and column column. In other words, each laser shoots in all non-diagonal directions until the border of the board. A robot starts at the one-based coordinates (curRow, curColumn). It can move only in a straight line within the board: left, right, up, or down. Return the maximum number of cells the robot can safely move through in any one direction before being destroyed by a laser. The initial cell is protected. Lasers cannot destroy the robot there even if that cell is within their destruction area. A solution with time complexity no worse than O(numRows * numColumns * laserCoordinates.length) will fit within the execution time limit. Function laserRobotSafePath(numRows: int, numColumns: int, curRow: int, curColumn: int, laserCoordinates: int[][]) → int Examples Example 1 numRows = 8 numColumns = 8 curRow = 5 curColumn = 3 laserCoordinates = [[1, 6], [2, 8]] return = 3 On the 8 x 8 board, the two lasers are centered at (1, 6) and (2, 8). The longest safe path available to the robot contains 3 cells. Constraints 8 <= numRows <= 20 8 <= numColumns <= 20 1 <= curRow <= numRows 1 <= curColumn <= numColumns 0 <= laserCoordinates.length <= 5 laserCoordinates[i].length = 2 1 <= laserCoordinates[i][0] <= numRows 1 <= laserCoordinates[i][1] <= numColumns The robot starts at a different cell from all laser centers.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The problem reduces to marking dangerous rows and columns, then simulating four straight walks. Put every laser row into a set and every laser column into a set. A cell is destroyed if its row or its column is in those sets. From the start, step one cell at a time in each direction, stop at the border or the first destroyed cell, count the safe steps, and return the max. The classic pitfall is the starting cell. It's protected, so don't check it, and don't count it as a step. Another trap is one-based coordinates, so keep your indexing consistent. Check Example 1: the robot at (5,3) going up passes rows 4, 3, 2, 1 in column 3, and the answer is 3, so row 1 is burned by the laser at (1,6). That confirms you count moved-through cells, excluding the start. StealthCoder is the fallback if you freeze 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 Laser Robot Safe Path 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 Capital One's OA.
Capital One 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.
Laser Robot Safe Path FAQ
How hard is Laser Robot Safe Path really?+
Easy. The constraints are tiny, 20 x 20 with at most 5 lasers, and the statement even allows O(rows * cols * lasers). No graph search or DP is needed. It's a simulation with a lookup, and most of the risk is off-by-one mistakes.
What's the trick to solving it fast?+
Store laser rows and laser columns in two sets. A cell is deadly if its row or column is in either set. Then walk up, down, left, and right from the start, counting cells until you hit a deadly one or the edge. Return the largest count.
Does the starting cell count as a step?+
No. The start is protected even if a laser covers it, so skip checking it. Begin counting from the first neighbor cell in each direction. Example 1 returns 3, which matches counting only cells you move into, not the cell you start on.
Is this a graph problem despite the hint?+
Not in practice. There's no branching or turning, since the robot only goes in one straight line. It's grid simulation. Don't build BFS or adjacency structures, because that just adds bugs without helping on a board this small.
How do I prepare for this in 48 hours?+
Practice grid walking with bounds checks and one-based to zero-based conversion. Write the four-direction loop using direction vectors, test it on Example 1, and try edge cases like zero lasers, a start on the border, and a start inside a laser's row or column.