← Meta Interview Insights

Meta·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Meta SWE coding round with a maze pathfinding problem. Pretty standard BFS territory but the I/O format tripped me up more than the actual algorithm did.

Questions Asked (1)

Q1

Given an n x m grid where 0 is a walkable cell and 1 is a wall, find the shortest path between two boundary points and output the coordinates along that path. If no path exists, output 'No Path'.

Algorithms & Data Structures
Author's notes

BFS was the obvious move and I knew that immediately, but I fumbled around with how to reconstruct the actual path coordinates instead of just returning a boolean or a length.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the grid as a graph and use BFS from one boundary point to find the shortest path to the other, since BFS guarantees the shortest path in unweighted graphs. During BFS, maintain a parent pointer for each visited cell to reconstruct the path once the target is reached. If the queue empties without reaching the target, return 'No Path'.

Pro tip: Clarify assumptions upfront: whether boundary points are guaranteed to be walkable, if diagonal moves are allowed, and if the path should include both endpoints. Also, mention that BFS is optimal here but if the grid is huge, bidirectional BFS can reduce search space.

1. Clarify the problem

Confirm the input format, movement rules (4-directional or 8-directional), and output format. Ask if the start and end are guaranteed to be walkable and distinct.

2. Choose BFS for shortest path

Explain that BFS is ideal for unweighted grids because it explores level by level, guaranteeing the shortest path. Mention that DFS would not guarantee shortest path.

3. Implement BFS with parent tracking

Use a queue to explore neighbors, a visited set to avoid cycles, and a parent map to record the previous cell for each visited cell. Stop when the target is reached.

4. Reconstruct and output the path

Backtrack from the target using the parent map to build the path from start to end. If the target was never reached, output 'No Path'.

5. Analyze complexity and edge cases

State time and space complexity: O(n*m) for both. Discuss edge cases like start equals end, no path, or blocked start/end.

Key Points to Mention

  • BFS guarantees shortest path in unweighted graphs
  • Use a queue for BFS and a visited set to avoid revisiting cells
  • Parent map or array to reconstruct the path
  • Time and space complexity: O(n*m)
  • Handling edge cases: start/end blocked, no path, start equals end
  • Potential optimization: bidirectional BFS for large grids

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