PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Meta

Solve grid path and robot navigation

Last updated: Mar 29, 2026

Quick Overview

This question evaluates proficiency in graph traversal and pathfinding, state representation for unknown environments, exploration and backtracking, and rigorous reasoning about correctness and time/space complexity.

  • Medium
  • Meta
  • Coding & Algorithms
  • Software Engineer

Solve grid path and robot navigation

Company: Meta

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Onsite

Part A — Shortest path in a grid with obstacles: Given an m×n grid of 0/1 cells (0 = open, 1 = obstacle), start at (0, 0) and end at (m−1,n− 1). You may move in four directions (up, down, left, right), each move costs 1. Return the length of the shortest path; return −1 if unreachable. Describe your algorithm, prove correctness, and analyze time/space complexity. Part B — Robot search in an unknown room (LeetCode-inspired, original prompt): You do not have the grid map. You control a robot in a finite 2D room with walls/obstacles. The robot starts at an arbitrary cell. Available APIs: - bool move(Direction d): attempts to move one cell in {up, down, left, right}; returns false if blocked and the robot stays put. - void turnLeft(), void turnRight() (optional; use if needed to manage orientation). - bool atTarget(): returns true if the current cell is the target. Design and implement an algorithm that explores the room, locates the target, and returns the minimal number of steps from the start to the target. Explain how you: ( 1) represent coordinates without a given grid, ( 2) avoid revisiting and handle backtracking, ( 3) ensure optimality of the returned step count, and ( 4) analyze complexity in terms of R, the number of reachable cells.

Quick Answer: This question evaluates proficiency in graph traversal and pathfinding, state representation for unknown environments, exploration and backtracking, and rigorous reasoning about correctness and time/space complexity.

Related Interview Questions

  • Solve Tree Columns And Maze Variants - Meta (medium)
  • Solve Tree Diameter and Palindromic Counts - Meta (medium)
  • Simulate Monster Team Battles - Meta (hard)
  • Solve a Key-Door Corridor Maze - Meta (medium)
  • Solve Array Merge and Parentheses Cleanup - Meta (medium)
Meta logo
Meta
Sep 6, 2025, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
3
0

Part A — Shortest path in a grid with obstacles: Given an m×n grid of 0/1 cells (0 = open, 1 = obstacle), start at (0, 0) and end at (m−1,n− 1). You may move in four directions (up, down, left, right), each move costs 1. Return the length of the shortest path; return −1 if unreachable. Describe your algorithm, prove correctness, and analyze time/space complexity.

Part B — Robot search in an unknown room (LeetCode-inspired, original prompt): You do not have the grid map. You control a robot in a finite 2D room with walls/obstacles. The robot starts at an arbitrary cell. Available APIs:

  • bool move(Direction d): attempts to move one cell in {up, down, left, right}; returns false if blocked and the robot stays put.
  • void turnLeft(), void turnRight() (optional; use if needed to manage orientation).
  • bool atTarget(): returns true if the current cell is the target. Design and implement an algorithm that explores the room, locates the target, and returns the minimal number of steps from the start to the target. Explain how you: (
  1. represent coordinates without a given grid, (
  2. avoid revisiting and handle backtracking, (
  3. ensure optimality of the returned step count, and (
  4. analyze complexity in terms of R, the number of reachable cells.

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Meta•More Software Engineer•Meta Software Engineer•Meta Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.