← Meta Interview Insights

Meta·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
Jul 2026

Summary

Meta SWE coding round with two questions back to back. The grid BFS problem was manageable but the robot cleaner one is a whole different beast and I was not ready for it.

Questions Asked (2)

Q1

Find the shortest path from the top-left to the bottom-right of a binary matrix where you can move in 8 directions and can only pass through cells with value 0.

Algorithms & Data Structures
Author's notes

BFS felt like the right call immediately and it was.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the problem constraints (e.g., matrix size, start/end values) and then propose BFS as the optimal solution since all moves have equal cost. Explain how to handle 8-directional movement and avoid revisiting cells, and analyze time and space complexity.

Pro tip: Mention that BFS guarantees the shortest path in an unweighted graph, and proactively discuss edge cases like unreachable destination or start/end being blocked. This shows thoroughness and prevents follow-up questions.

1. Clarify the problem

Ask about matrix dimensions, whether start and end are always 0, and if diagonal moves are allowed through corners. Confirm that each move costs 1.

2. Choose BFS

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

3. Outline BFS algorithm

Initialize a queue with the start cell and a visited set. For each cell, explore all 8 neighbors that are within bounds, have value 0, and are unvisited; mark visited and enqueue. Track distance or use level-order traversal.

4. Handle edge cases

Check if start or end is blocked (value 1) and return -1. Also handle cases where the destination is unreachable.

5. Analyze complexity

Time complexity is O(R*C) since each cell is visited at most once. Space complexity is O(R*C) for the queue and visited set in the worst case.

Key Points to Mention

  • BFS guarantees shortest path in unweighted graphs
  • 8-directional movement: include diagonals
  • Visited set to avoid cycles and redundant work
  • Time and space complexity: O(R*C)
  • Edge cases: start/end blocked, unreachable destination
  • Alternative: bidirectional BFS for optimization

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

Q2

Given a robot vacuum API that lets you move, turn, and clean but gives you no information about the grid or your position, write an algorithm to clean the entire reachable room.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

This one genuinely stumped me for a bit.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Treat the problem as online graph exploration with no prior map, using a systematic traversal strategy like spiral or wall-following with backtracking to ensure full coverage. Emphasize that the robot must maintain its own state (position and orientation) and use a stack to backtrack when stuck, while handling obstacles and avoiding infinite loops.

Pro tip: Mention that in practice, you'd augment the algorithm with sensor fusion or SLAM for robustness, but for this problem, assume perfect odometry and focus on the traversal logic. Also, discuss trade-offs between coverage time and memory usage.

1. Clarify assumptions and constraints

Ask about the robot's movement primitives (e.g., move forward one cell, turn 90 degrees), whether it can detect obstacles, and if it can track its position relative to start. Confirm that the room is bounded and connected.

2. Choose a traversal strategy

Select a systematic exploration method such as spiral search, wall-following (e.g., always keep right), or depth-first search with backtracking. Justify why it guarantees coverage.

3. Design the algorithm with state management

Outline how the robot maintains its position, orientation, and a stack of visited cells for backtracking. Describe how it decides the next move based on sensor input and coverage status.

4. Analyze correctness and complexity

Prove that the algorithm visits every reachable cell and terminates. Discuss time complexity (e.g., O(N) moves for N cells) and space complexity (e.g., O(N) for the stack).

5. Discuss optimizations and trade-offs

Mention potential improvements like using a heuristic to reduce backtracking, or handling dynamic obstacles. Compare with alternative approaches like random walk (not guaranteed) or SLAM-based mapping.

Key Points to Mention

  • Online graph exploration and coverage path planning
  • Use of backtracking with a stack to handle dead ends
  • Wall-following or spiral algorithms for systematic coverage
  • State representation: position, orientation, and visited cells
  • Termination condition: when all reachable cells are visited
  • Trade-offs between coverage time, memory, and robustness

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