← Meta Interview Insights

Meta·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
May 2026Remote

Summary

Meta SWE coding round, one question the whole time. Pretty standard graph traversal but with a twist that tripped me up more than I expected.

Questions Asked (1)

Q1

Given an n x n binary grid where 0 is open and 1 is blocked, find the shortest path from the top-left to the bottom-right cell using 8-directional movement. Return the actual list of coordinates on the path, not just the length.

Algorithms & Data Structures
Author's notes

I knew BFS immediately, got that part out fast.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Use BFS with 8-directional movement to find the shortest path, since BFS guarantees the shortest path in an unweighted grid. Track parent pointers for each visited cell to reconstruct the path from start to end, and handle edge cases like blocked start/end or no path.

Pro tip: Clarify whether diagonal moves are allowed to pass through blocked cells (e.g., if both adjacent orthogonal cells are blocked). Also, mention that BFS explores level by level, so the first time you reach the target, you have the shortest path.

1. Clarify problem and edge cases

Confirm movement rules (8 directions, diagonal allowed even if adjacent cells blocked?), grid boundaries, and what to return if no path exists. Check if start or end is blocked.

2. Choose BFS and initialize data structures

Use a queue for BFS, a visited set or 2D array to avoid revisiting, and a parent map or 2D array to store the predecessor of each cell for path reconstruction.

3. Perform BFS level by level

Start from (0,0), explore all 8 neighbors, skip blocked or out-of-bounds cells, and mark visited. Stop when reaching (n-1, n-1).

4. Reconstruct and return the path

If target reached, backtrack from target to start using parent pointers, reverse the list, and return it. If queue empties without reaching target, return empty list or indicate no path.

5. Analyze complexity and test

State time and space complexity: O(n^2) since each cell visited once. Walk through a small example to verify correctness, including edge cases.

Key Points to Mention

  • BFS guarantees shortest path in unweighted graphs
  • Use of parent pointers for path reconstruction
  • Handling of 8-directional movement and boundary checks
  • Edge cases: blocked start/end, no path, n=1
  • Time and space complexity: O(n^2)
  • 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.