← Meta Interview Insights

Meta·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Meta coding screen, pretty much one question the whole time. BFS on a grid, which I've done before but still managed to fumble parts of it under pressure.

Questions Asked (1)

Q1

Given a 2D grid with a start cell, a goal cell, and some walls, find the shortest path from start to goal. You can move in four directions and each step costs one unit. Return either the path itself or its length.

Algorithms & Data Structures
Author's notes

I knew it was BFS the second I read it, which almost made it worse because I got overconfident and skipped thinking through edge cases.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the grid as an unweighted graph and use BFS to find the shortest path from start to goal. Reconstruct the path by storing parent pointers during traversal, or simply return the distance when the goal is reached.

Pro tip: Clarify upfront whether the path or just the length is needed, and discuss trade-offs between BFS and A* if the grid is large or has obstacles. Mention that BFS guarantees the shortest path in unweighted grids, while A* can be faster with a good heuristic.

1. Clarify requirements and constraints

Ask whether to return the path or just the length, and confirm movement rules, grid size, and whether diagonal moves are allowed. This ensures you solve the exact problem.

2. Choose BFS as the core algorithm

Explain that BFS explores level by level, guaranteeing the shortest path in an unweighted grid. Mention that each cell is a node and edges connect adjacent non-wall cells.

3. Outline BFS implementation details

Describe using a queue, a visited set or 2D array, and parent pointers to reconstruct the path. Track distance as you go if only the length is needed.

4. Handle edge cases and complexity

Discuss cases like start equals goal, unreachable goal, or empty grid. State time and space complexity: O(R*C) for both, where R and C are grid dimensions.

5. Optimize and discuss alternatives

Mention that A* with Manhattan distance can be more efficient for large grids, and bidirectional BFS can reduce search space. Note that BFS is optimal for unweighted grids.

Key Points to Mention

  • BFS guarantees shortest path in unweighted graphs
  • Use a queue for level-order traversal
  • Track visited cells to avoid cycles
  • Reconstruct path using parent pointers if needed
  • Time and space complexity: O(R*C)
  • Edge cases: start == goal, unreachable goal, walls blocking

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