← Meta Interview Insights

Meta·Data Scientist·Technical Phone Screen·Senior

Senior
Sep 2025Remote

Summary

Meta data scientist technical screen, basically one massive SQL problem that kept growing in scope. The question was about detecting latent demand for a group calling feature and it went deep fast, recursive CTEs and all.

Questions Asked (4)

Q1

Given only a 1:1 calls table and a users table, use SQL to estimate latent demand for a group call feature by identifying 10-minute windows where 3 or more distinct users are connected through overlapping or back-to-back 1:1 calls. Build an undirected edge view first, then explain when to use UNION vs UNION ALL and the deduplication pitfalls involved.

Data ModelingTechnical Trade-offs
Author's notes

The UNION vs UNION ALL piece sounds like a throwaway but it actually matters here.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by transforming the 1:1 calls table into an undirected edge list using UNION (not UNION ALL) to deduplicate reciprocal call pairs. Then, for each edge, generate all 10-minute windows that contain the call, and self-join these windows to find groups of 3 or more distinct users connected via overlapping or back-to-back calls. Finally, count distinct user sets per window to estimate latent demand.

Pro tip: Explicitly discuss the trade-off between UNION and UNION ALL: UNION removes duplicates but adds a sort/hash step, while UNION ALL is faster but requires careful deduplication later. In production, use UNION ALL for performance and deduplicate with DISTINCT or GROUP BY only when necessary.

1. Build undirected edge view

Use UNION to combine caller-receiver and receiver-caller pairs into a single undirected edge list, ensuring each pair appears once. This avoids double-counting reciprocal calls.

2. Generate 10-minute windows

For each edge, create all possible 10-minute windows that contain the call by expanding the start and end times. This captures overlapping and back-to-back calls.

3. Identify connected components

Self-join the windowed edges on overlapping windows to find sets of users connected through a chain of calls within the same 10-minute window.

4. Filter and count distinct users

Filter for windows with at least 3 distinct users and count the number of such windows or distinct user groups to estimate latent demand.

5. Explain UNION vs UNION ALL

Discuss when to use UNION (deduplication) vs UNION ALL (performance) and the pitfalls of deduplication, such as missing reciprocal calls or double-counting.

Key Points to Mention

  • Undirected edge representation: ensure each pair is counted once using UNION or by ordering user IDs.
  • Window generation: consider both overlapping and back-to-back calls by expanding time intervals.
  • UNION vs UNION ALL: UNION deduplicates but is slower; UNION ALL is faster but requires explicit deduplication.
  • Deduplication pitfalls: double-counting reciprocal calls, missing edges due to incorrect ordering, and performance impact of DISTINCT.
  • Scalability: use efficient joins and avoid cross joins; consider indexing on user IDs and time.
  • Latent demand estimation: define a metric (e.g., number of 10-minute windows with 3+ users) and discuss limitations.

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

Q2

Using the undirected edge view, sessionize calls into rolling 10-minute windows and write a recursive CTE to find connected components across those sessions.

Algorithms & Data StructuresData Modeling
Author's notes

This is where I slowed down noticeably.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify the data schema and the definition of a session (e.g., calls within 10 minutes of each other). Then, describe how to sessionize calls using a rolling window (e.g., with a self-join or window functions), and finally, explain how to build a graph from sessions and use a recursive CTE to find connected components. Emphasize the undirected edge view: each call is an edge between two users, and sessions group edges that are close in time.

Pro tip: Mention that recursive CTEs can be inefficient for large graphs and suggest alternatives like iterative BFS with temporary tables or using graph processing frameworks, showing awareness of scalability. Also, clarify that the rolling window is based on call start times and that sessions may overlap, which affects component definition.

1. Clarify requirements and data model

Ask about the call data schema (caller, callee, start_time, end_time) and confirm that sessions are defined by calls within a 10-minute rolling window. Clarify whether the window is based on start times or overlapping intervals.

2. Sessionize calls into rolling 10-minute windows

Use a self-join or window functions to group calls into sessions where each call is within 10 minutes of another call in the same session. For example, assign a session ID by finding connected calls based on time proximity.

3. Build an undirected graph from sessions

Treat each user as a node and each call as an undirected edge. Within each session, the edges form a subgraph; the overall graph is the union of edges across all sessions.

4. Write a recursive CTE to find connected components

Use a recursive CTE to traverse the graph: start with each node, recursively follow edges to find all reachable nodes, and assign a component ID (e.g., the minimum node ID in the component).

5. Discuss optimization and edge cases

Address performance considerations (e.g., indexing, limiting recursion depth) and edge cases (isolated nodes, overlapping sessions, duplicate edges).

Key Points to Mention

  • Definition of a session: calls within a 10-minute rolling window, possibly using a self-join on time intervals.
  • Undirected edge view: each call is an edge between two users, and connected components are sets of users linked by calls.
  • Recursive CTE structure: anchor member selects base nodes, recursive member joins edges to expand the component.
  • Handling cycles: use a visited set or path array to avoid infinite recursion.
  • Performance: recursive CTEs may not scale; consider iterative BFS or graph libraries for large datasets.
  • Output format: component ID (e.g., min user ID) and list of users in each component.

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

Q3

For each day in the last 7 days, output the number of loop sessions, unique users involved in loops, and an 'unmet connectivity' metric per session defined as n*(n-1)/2 minus the observed unique pairs, then aggregate that metric per day.

Product Analytics & MetricsData Modeling
Author's notes

The n*(n-1)/2 formula is just the maximum possible edges in a complete graph minus what you actually saw.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the definitions of 'loop session', 'unique users', and 'observed unique pairs' to ensure alignment. Then outline a SQL-based approach: first compute per-session metrics (user count, observed pairs, unmet connectivity), then aggregate by day over the last 7 days. Finally, discuss potential edge cases and validation.

Pro tip: Mention that the unmet connectivity metric assumes a fully connected graph per session; if sessions are large, this may be computationally heavy, so consider sampling or approximation for scale. Also, highlight the importance of handling sessions with only one user (where n*(n-1)/2 = 0).

1. Clarify Definitions and Assumptions

Confirm what constitutes a 'loop session' (e.g., time-bounded, event-based) and how 'unique users' and 'observed unique pairs' are defined. Discuss whether pairs are directed or undirected.

2. Compute Per-Session Metrics

For each session, calculate the number of unique users (n), the number of observed unique pairs (e.g., via self-join on user pairs within session), and then unmet connectivity = n*(n-1)/2 - observed_pairs.

3. Aggregate by Day

Group sessions by day (using session start date or date of activity) and sum the per-session metrics: count of sessions, sum of unique users (or distinct users per day?), and sum of unmet connectivity.

4. Filter Last 7 Days and Output

Restrict to the last 7 days relative to the current date, and present the results with columns: date, session_count, unique_users, total_unmet_connectivity.

5. Validate and Discuss Edge Cases

Check for sessions with 0 or 1 user, missing data, and timezone considerations. Discuss how to handle sessions spanning multiple days.

Key Points to Mention

  • Definition of a session (e.g., 30-minute inactivity window) and how it impacts the analysis.
  • Calculation of observed unique pairs: use self-join on session_id and user_id where user1 < user2 to avoid double-counting.
  • Handling of sessions with only one user: unmet connectivity is 0, but unique users count as 1.
  • Aggregation of unique users per day: should it be distinct users across all sessions that day, or sum of per-session unique users? Clarify.
  • Time zone and date boundaries: ensure 'last 7 days' is based on a consistent timezone and includes complete days.
  • Performance considerations: for large datasets, computing all pairs per session can be expensive; consider approximations or pre-aggregation.

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

Q4

Calls with connected=0 should be excluded from the main edge graph, but describe how you would incorporate them as failed attempts in a sensitivity variant of the analysis.

Product Analytics & MetricsA/B Testing & Experimentation
Author's notes

Short answer I gave: create a parallel edge set with connected=0 calls, compute the same loop detection logic, then compare loop session counts between the two variants to see how much latent demand you might be underestimating.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify the rationale for excluding connected=0 calls from the main edge graph, emphasizing data quality and relevance. Then, propose a sensitivity analysis that treats these calls as failed attempts, defining a separate graph or metric to capture their impact. Finally, discuss how to compare results between the main and sensitivity analyses to assess robustness.

Pro tip: Frame the sensitivity analysis as a way to test the robustness of your conclusions to data inclusion criteria, which is crucial for building trust with stakeholders. Also, mention that you would pre-register the sensitivity analysis to avoid p-hacking concerns.

1. Clarify exclusion criteria

Explain why connected=0 calls are excluded from the main edge graph, such as they represent failed connection attempts and do not contribute to the intended network structure.

2. Define sensitivity variant

Propose incorporating connected=0 calls as failed attempts by creating a separate graph or adding a failure indicator, ensuring they are analyzed distinctly from successful connections.

3. Choose metrics and methods

Select appropriate metrics (e.g., failure rate, impact on centrality) and methods (e.g., weighted edges, separate failure nodes) to quantify the effect of including failed attempts.

4. Compare and interpret

Compare results from the main and sensitivity analyses to assess how sensitive conclusions are to the exclusion of connected=0 calls, and interpret any differences.

5. Communicate implications

Summarize the findings, highlighting whether the main conclusions hold and what the sensitivity analysis reveals about potential biases or robustness.

Key Points to Mention

  • Data quality and relevance: connected=0 calls may indicate failed attempts or spam, which could skew network metrics.
  • Sensitivity analysis purpose: to test robustness of findings to data inclusion/exclusion decisions.
  • Method for incorporation: e.g., adding a binary 'failed' attribute to edges or creating a separate failure graph.
  • Metrics to compare: e.g., degree distribution, centrality measures, community structure, with and without failed attempts.
  • Potential biases: excluding failed attempts might overestimate connectivity or engagement.
  • Stakeholder communication: clearly explain why the main analysis excludes them and how the sensitivity analysis provides additional context.

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