← Meta Interview Insights

Meta·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
May 2026

Summary

Meta software engineering interview with two coding problems back to back. Nothing too exotic but the second one had a wrinkle I didn't see coming at first.

Questions Asked (2)

Q1

Given an m×n binary grid where 1s are blocked cells and 0s are passable, determine whether a path exists from the top-left to the bottom-right corner using up/down/left/right movement.

Algorithms & Data Structures
Author's notes

Went with BFS pretty quickly, felt solid.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the problem constraints (grid size, memory limits) and edge cases (start or end blocked). Then propose a graph traversal (BFS or DFS) treating each passable cell as a node, and discuss trade-offs between BFS (shortest path) and DFS (simpler, but may hit recursion limits). Finally, analyze time and space complexity and consider optimizations like in-place marking or bidirectional search.

Pro tip: Mention that you can avoid extra space by marking visited cells in-place (e.g., set to 1), but note that this mutates the input; if mutation is not allowed, use a separate visited set. Also, for very large grids, consider iterative DFS to avoid stack overflow.

1. Clarify constraints and edge cases

Ask about grid dimensions, whether the start or end can be blocked, and if modifying the grid is allowed. Confirm movement is only up/down/left/right.

2. Choose traversal algorithm

Select BFS for shortest path or DFS for simplicity. Explain that both work for reachability, but BFS is often preferred for pathfinding.

3. Implement traversal with visited tracking

Use a queue (BFS) or stack (DFS) to explore neighbors, marking cells as visited to avoid cycles. Check boundaries and passability (0).

4. Analyze complexity and optimizations

State O(m*n) time and space. Discuss in-place marking, bidirectional BFS, or early termination when target is reached.

5. Test with edge cases

Walk through examples: empty grid, start blocked, end blocked, single row/column, and a grid with no path.

Key Points to Mention

  • Graph traversal: BFS vs DFS trade-offs (shortest path vs memory/recursion)
  • Visited tracking to avoid infinite loops, with options for in-place marking or separate set
  • Time and space complexity: O(m*n) for both, with space O(m*n) worst case
  • Edge cases: start/end blocked, 1x1 grid, no path, all passable
  • Optimizations: bidirectional BFS, early exit, iterative DFS to avoid stack overflow
  • Problem constraints: grid size, memory limits, and whether mutation is allowed

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

Q2

Given an integer array and a value k, return the k most frequently occurring numbers. Ties in frequency can be broken arbitrarily.

Algorithms & Data Structures
Author's notes

I jumped to a full sort by frequency which works but is O(n log n).

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem constraints (e.g., input size, value range, expected time/space complexity) and then propose a solution using a hash map to count frequencies followed by a heap or bucket sort to extract the top k. Discuss trade-offs between different approaches and analyze time/space complexity.

Pro tip: Mention that if the input is very large and k is small, a min-heap of size k is more space-efficient than sorting all unique elements. Also, if the value range is known and small, bucket sort can achieve O(n) time.

1. Clarify requirements and constraints

Ask about input size, value range, whether k is always valid, and if the output order matters. This shows attention to detail and helps choose the optimal approach.

2. Count frequencies

Use a hash map to count the occurrence of each number. This takes O(n) time and O(n) space.

3. Select top k frequent elements

Use a min-heap of size k to keep the k most frequent elements, or use bucket sort if the frequency range is bounded. Discuss trade-offs.

4. Analyze complexity and edge cases

State the time and space complexity of your approach. Consider edge cases like k=0, k larger than unique elements, or empty input.

5. Test with examples

Walk through a small example to verify correctness and explain how ties are handled arbitrarily.

Key Points to Mention

  • Hash map for frequency counting
  • Min-heap of size k for O(n log k) time
  • Bucket sort for O(n) time when frequency range is bounded
  • Time and space complexity analysis
  • Handling edge cases (k=0, k > unique count, empty array)
  • Trade-offs between sorting, heap, and bucket sort approaches

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