← Meta Interview Insights

Meta·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Meta data engineer technical screen, one coding question the whole time. Pretty focused on graph traversal which I wasn't expecting for a DE role, but it wasn't impossible.

Questions Asked (1)

Q1

Given a directed 'follows' graph represented as a Python dict mapping users to lists of users they follow, implement a function that returns two-hop recommendations for a given user. These are accounts followed by the user's followees that the user doesn't already follow, excluding the user themselves. If returning a list, sort by descending frequency then lexicographically.

Algorithms & Data Structures
Author's notes

The base case clicked pretty fast: loop over followees, then loop over who they follow, filter out anyone the user already follows and the user themselves, deduplicate.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the input format and edge cases, then iterate through the user's followees, collecting their followees into a frequency map while excluding the user and anyone the user already follows. Finally, sort the candidates by descending frequency and lexicographically, and return the sorted list.

Pro tip: Mention that you'd handle missing users gracefully by returning an empty list, and discuss the time complexity trade-offs between using a set for O(1) lookups versus sorting at the end.

1. Clarify requirements and edge cases

Confirm the graph representation, whether the user exists, and how to handle ties. Ask about expected output format (list vs. set) and if sorting is required.

2. Collect two-hop candidates

Iterate over the user's followees, and for each, iterate over their followees. Skip the user themselves and anyone the user already follows.

3. Count frequencies

Use a dictionary to count how many times each candidate appears across the followees' follow lists.

4. Sort and return

Sort the candidates by descending frequency, then lexicographically for ties. Return the sorted list.

Key Points to Mention

  • Time complexity: O(F * A + C log C) where F is number of followees, A is average followees per followee, and C is number of candidates.
  • Space complexity: O(C) for the frequency map and output list.
  • Use a set for the user's existing follows to enable O(1) membership checks.
  • Handle edge cases: user not in graph, no followees, no recommendations.
  • Sorting with a custom key: (-frequency, username) to achieve descending frequency and lexicographic order.
  • Potential follow-up: scaling to large graphs with distributed processing or using heaps for top-k recommendations.

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