PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Meta

Extend a Maze Solver

Last updated: Apr 6, 2026

Quick Overview

This question evaluates competence in graph search and state-space modeling, specifically BFS-based pathfinding, constrained traversal rules (directional cells), and handling dynamic state such as collected keys and doors.

  • hard
  • Meta
  • Coding & Algorithms
  • Machine Learning Engineer

Extend a Maze Solver

Company: Meta

Role: Machine Learning Engineer

Category: Coding & Algorithms

Difficulty: hard

Interview Round: Onsite

You are given an existing Python maze solver and a suite of unit tests. The maze is a 2D grid that uses `#` for walls, `.` for open cells, `S` for the start, and `E` for the exit. The current implementation uses BFS and reconstructs a path. Make the tests pass by fixing bugs and adding features in stages: 1. When printing the final path, mark path cells with `*` but do not overwrite `S` or `E`. 2. Prevent BFS from revisiting the same state indefinitely. 3. Support one-way chutes: a cell `>` can only be traversed from left to right, and a cell `<` can only be traversed from right to left. 4. Support keys and doors: collecting lowercase keys `a` to `z` allows passing through the matching uppercase doors `A` to `Z`. Because reachability changes after collecting keys, the visited structure must include both position and key set. Return whether a path exists, and when requested reconstruct one valid path that satisfies all rules.

Quick Answer: This question evaluates competence in graph search and state-space modeling, specifically BFS-based pathfinding, constrained traversal rules (directional cells), and handling dynamic state such as collected keys and doors.

Related Interview Questions

  • Find Shortest Unique Prefixes - Meta (medium)
  • Compute Exclusive Execution Times - Meta (medium)
  • Solve Tree Columns And Maze Variants - Meta (medium)
  • Solve Tree Diameter and Palindromic Counts - Meta (medium)
  • Simulate Monster Team Battles - Meta (hard)
Meta logo
Meta
Mar 1, 2026, 12:00 AM
Machine Learning Engineer
Onsite
Coding & Algorithms
3
0
Loading...

You are given an existing Python maze solver and a suite of unit tests. The maze is a 2D grid that uses # for walls, . for open cells, S for the start, and E for the exit. The current implementation uses BFS and reconstructs a path. Make the tests pass by fixing bugs and adding features in stages:

  1. When printing the final path, mark path cells with * but do not overwrite S or E .
  2. Prevent BFS from revisiting the same state indefinitely.
  3. Support one-way chutes: a cell > can only be traversed from left to right, and a cell < can only be traversed from right to left.
  4. Support keys and doors: collecting lowercase keys a to z allows passing through the matching uppercase doors A to Z . Because reachability changes after collecting keys, the visited structure must include both position and key set. Return whether a path exists, and when requested reconstruct one valid path that satisfies all rules.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Meta•More Machine Learning Engineer•Meta Machine Learning Engineer•Meta Coding & Algorithms•Machine Learning Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,000+ 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.