FastPrepExplore an Unknown Grid and Find a Path
Problems/Explore an Unknown Grid and Find a Path

Explore an Unknown Grid and Find a Path

LinkedIn logoLinkedIn● MediumFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a LinkedIn onsite interview. The report describes an unexplored matrix and a robot. The robot can turn, move, sense a wall, and go back to cells it has explored. The goal is to find a path. The report leaves out how the judge talks to your code, how to break ties in the output, how coordinates are written, and what to do when the goal cannot be reached. Here, the map is a finite simulated one. Our version is about 93% the same as the reported question.

A robot starts in an unexplored rectangular area. In this version, hiddenMap is the map the robot cannot see: . 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.

The hidden map tells the robot what it finds at each cell it inspects.

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.

More LinkedIn Onsite Interview questions

  • Allocate Mailboxes with Squared DistanceONSITE INTERVIEW · Seen Nov 2026
  • Find Leaves of a Binary TreeONSITE INTERVIEW · Seen Nov 2026
  • Max Points on a LineONSITE INTERVIEW · Seen Nov 2026
  • Fire Station Response BillONSITE INTERVIEW · Seen Nov 2026
  • Roll a Weighted DieONSITE INTERVIEW · Seen Oct 2026
  • Longest Binary Subarray With at Most K OnesONSITE INTERVIEW · Seen Oct 2026
  • Kth Closest Element in a BSTONSITE INTERVIEW · Seen Oct 2026
  • Longest Binary Window with at Most K OnesONSITE INTERVIEW · Seen Oct 2026
  • LRU Cache OperationsONSITE INTERVIEW · Seen Oct 2026
  • Lexicographically Smallest Course OrderONSITE INTERVIEW · Seen Oct 2026

Similar questions at other companies

  • Xiangqi Horse ReachabilityeBay · PHONE SCREENeBay interview questions
  • Number of IslandsAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • 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
  • Grid Pathfinding with Obstacles (DFS)Roblox · PHONE SCREEN · ONSITE INTERVIEWRoblox interview questions

Interview reports that mention this question

  • LinkedIn Experienced MLE Onsite: 1 Experience

LinkedIn interview experiences

  • LinkedIn Senior MLE Interview Questions: 1 Experience
  • LinkedIn Staff AI Engineer Phone Screens: 1 Experience
  • LinkedIn Coding with AI Interview: 4 Experiences
  • LinkedIn Experienced Infrastructure SWE Onsite: 1 Experience
All LinkedIn interview questionsSee LinkedIn hiring insights
Saved
class Solution {
    public int[][] findExploredPath(String[] hiddenMap, int[] start, int[] target) {
        // Write your code here.
    }
}
Checking account…