Reported September 2026
LinkedInbreadth first search

Explore an Unknown Grid and Find a Path

Reported by candidates from LinkedIn's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live LinkedIn OA. Under 2s to a working solution.
Founder's read

The whole problem hinges on one data structure: a queue. LinkedIn's September 2026 OA dresses up a plain grid shortest path as a robot exploring an unknown map, but the hidden matrix just hands you deterministic neighbor info. If you've got an invite and 48 hours, this is breadth-first search with one annoying twist: the lexicographically smallest path among all shortest ones. The robot relocation talk is flavor. Any explored open cell is reachable for free, so it doesn't change the answer. StealthCoder is the invisible safety net if you blank on the tie-break during the live OA, but you can know the trick before you sit down.

The problem

A robot starts in an unexplored rectangular area. For this deterministic adapter, hiddenMap contains the environment:. is an open cell and # is a wall. The robot starts at start = [row, column], knows the target coordinate, and may inspect the four orthogonal neighbors of any cell it has already explored. It may also relocate to any previously explored open cell before continuing exploration.
Return a shortest open-cell path from start to target, including both endpoints. If several shortest paths exist, choose the lexicographically smallest coordinate sequence when coordinates are compared as [row, column]. Return an empty array when the target cannot be reached.
This finite adapter preserves the reported exploration and relocation state transitions; the hidden matrix supplies deterministic sensor outcomes for the judge.

Function
findExploredPath(hiddenMap: String[], start: int[], target: int[]) → int[][]

Examples
Example 1
hiddenMap = ["...",".#.","..."]
start = [0,0]
target = [2,2]
return = [[0,0],[0,1],[0,2],[1,2],[2,2]]
Two shortest paths have four moves. The path beginning with [0,1] is lexicographically smaller than the one beginning with [1,0].
Example 2
hiddenMap = [".#.","###",".#."]
start = [0,0]
target = [2,2]
return = []
Walls separate the target from the start.

Constraints
1 <= hiddenMap.length, hiddenMap[i].length <= 500.
All rows have equal length and contain only. and #.
start and target identify open cells.
The robot explores only up, down, left, and right neighbors.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Run BFS from the target, not the start. Store each cell's distance to the target. Then walk forward from start: at each step, look at the four neighbors whose distance is exactly one less than the current cell's, and pick the smallest by [row, column]. That gives the lexicographically smallest shortest path with no sorting of full paths. The common pitfall is running BFS from the start and trying to keep the best parent. That fails because a smaller early choice can still lead to a worse later one, and parent pointers get messy. Another pitfall is forgetting the unreachable case, which must return an empty array. The grid goes up to 500 by 500, so avoid recursion and use an iterative queue with a visited array. If you freeze on the reverse-BFS idea mid-assessment, StealthCoder can surface it while you type.

The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.

If this hits your live OA

You can drill Explore an Unknown Grid and Find a 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. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass LinkedIn's OA.

LinkedIn reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Explore an Unknown Grid and Find a Path FAQ

What's the trick in this LinkedIn OA problem?+

Do BFS backward from the target to get a distance for every open cell. Then walk forward from start, always stepping to the smallest [row, column] neighbor whose distance is one less. That gives the lexicographically smallest shortest path directly.

Does the robot relocation rule change the algorithm?+

No. The robot can jump to any explored open cell, so exploration order doesn't cost you anything. The hidden map gives deterministic results, so you can treat it as a normal grid and run standard BFS over open cells.

How hard is this really?+

Medium. BFS on a grid is standard. The lexicographic tie-break is what trips people up. If you know the reverse-BFS-then-greedy-walk approach, it's maybe 30 lines. Without it, you'll waste time on parent pointer hacks that break.

What edge cases should I test?+

Start equals target, which should return a single-cell path. An unreachable target returns an empty array, like Example 2. Also test a 1 by 1 grid, a single-row grid, and a large open 500 by 500 grid to check you don't blow the stack or time.

How do I prepare in 48 hours?+

Write grid BFS from scratch twice with a visited array and a direction list. Then add the reverse-BFS plus greedy forward walk for tie-breaking. Test on Example 1 by hand. Make sure your queue is iterative, since grids can reach 500 by 500.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with LinkedIn.

OA at LinkedIn?
Invisible during screen share
Get it