← Meta Interview Insights

Meta·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jul 2026

Summary

Meta Production Engineer interview with a coding problem about social graph friend requests. Pretty standard algorithm question but the conditions tripped me up more than I expected.

Questions Asked (1)

Q1

Given an array of ages for n people on a social media platform, count the total number of friend requests sent, given a specific set of rules about when a person will or won't send a request to another person.

Algorithms & Data Structures
Author's notes

The three conditions look simple but I kept getting off-by-one errors because of the half-age-plus-seven rule.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the exact rules for when a friend request is sent (e.g., age difference, direction, mutual conditions). Then design an algorithm that counts valid pairs efficiently, likely using sorting and binary search or a frequency map to avoid O(n^2) brute force.

Pro tip: Always ask clarifying questions about edge cases (e.g., same age, boundary conditions) and state the time/space complexity of your solution. Meta values clean, optimized code and clear communication.

1. Clarify the rules

Ask the interviewer to specify the exact conditions under which a friend request is sent. For example, if it's based on age difference (e.g., |ageA - ageB| <= 2) and direction (e.g., older sends to younger), or if it's mutual.

2. Define the counting problem

Restate the problem as counting ordered or unordered pairs (i, j) that satisfy the given conditions. Determine if each pair can send at most one request or if both can send.

3. Choose an efficient algorithm

Sort the ages and use two pointers or binary search to count valid pairs in O(n log n) time. Alternatively, use a frequency map if ages are bounded (e.g., 1-120) to achieve O(n + range) time.

4. Handle edge cases and duplicates

Consider cases like multiple people with the same age, boundary ages, and whether requests are counted once or twice. Adjust counting logic accordingly.

5. Analyze complexity and test

State the time and space complexity of your solution. Walk through a small example to verify correctness, and discuss potential optimizations or trade-offs.

Key Points to Mention

  • Clarify the exact rules: age difference threshold, direction of request, and whether requests are mutual.
  • Use sorting and binary search or two-pointer technique to achieve O(n log n) time complexity.
  • Consider using a frequency array if age range is small (e.g., 1-120) for O(n) time.
  • Handle duplicates and boundary conditions carefully to avoid overcounting or undercounting.
  • Discuss time and space complexity trade-offs between different approaches.
  • Test with edge cases like all same ages, minimum and maximum ages, and empty array.

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