← Meta Interview Insights

Meta·Software Engineer·Technical Phone Screen·Senior

SeniorPrefer not to say
Apr 2026

Summary

Interviewed for a Supply Chain Capacity Engineer role at Meta and got hit with a maze pathfinding problem. Pretty classic BFS territory but they wanted you to actually talk through the tradeoffs, not just code it.

Questions Asked (1)

Q1

Given a 2D grid maze with walls, a start position, and a target position, determine whether the target is reachable and if so, what is the minimum number of steps to get there? Movement is restricted to four directions only.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

I went straight to BFS which was the right call for shortest path, but I spent probably too long explaining it before writing any code.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the maze as a graph where each cell is a node and edges connect adjacent non-wall cells. Use BFS to find the shortest path from start to target, as BFS guarantees the minimum number of steps in an unweighted grid. If the target is unreachable, BFS will exhaust all reachable cells and return -1.

Pro tip: In interviews, always clarify edge cases upfront (e.g., start equals target, empty grid, no path) and discuss time/space complexity. Mention that BFS is optimal for unweighted graphs, but if the grid is huge, consider bidirectional BFS or A* with Manhattan distance heuristic to reduce search space.

1. Clarify the problem and constraints

Ask about grid dimensions, movement rules, whether diagonal moves are allowed, and if the start or target can be on walls. Confirm that you need the minimum number of steps, not just reachability.

2. Choose the right algorithm

Explain that BFS is ideal because it explores level by level, guaranteeing the shortest path in an unweighted grid. Mention alternatives like DFS (not optimal for shortest path) and A* (if heuristic is available).

3. Outline the BFS implementation

Describe using a queue to store cells and their distances, a visited set to avoid cycles, and directional offsets for the four moves. Initialize with the start cell and distance 0.

4. Handle edge cases and termination

Check if start equals target (return 0), if start or target is a wall (return -1), and if the queue empties without finding the target (return -1). Also consider grid boundaries.

5. Analyze complexity and optimizations

State that time complexity is O(R*C) since each cell is visited once, and space is O(R*C) for the queue and visited set. Discuss potential optimizations like bidirectional BFS or early exit when target is found.

Key Points to Mention

  • BFS guarantees shortest path in unweighted graphs
  • Use a queue for level-order traversal and track distance
  • Visited set prevents revisiting cells and infinite loops
  • Edge cases: start == target, start/target on wall, no path
  • Time and space complexity: O(R*C) for an R x C grid
  • Possible optimizations: bidirectional BFS, A* with Manhattan distance

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.