← Meta Interview Insights

Meta·Data Scientist·Technical Phone Screen·Senior

Senior
Jul 2026Remote

Summary

Meta DS interview with a pretty brutal SQL question covering anomaly investigation across multiple tables. The whole thing felt like a take-home that somehow ended up in a live session, lots of moving parts and edge cases they clearly expected you to handle without prompting.

Questions Asked (4)

Q1

For each country and post type on a given date, compute Likes-per-DAU and its percent change versus the median value for the same weekday over the prior 8 weeks, excluding dates with an outage flag. Use window functions like PERCENTILE_CONT and pull DAU from the DailyActiveUsers table rather than counting users yourself.

Product Analytics & MetricsData ModelingRoot Cause Analysis
Author's notes

This is where I spent most of my mental energy.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Break the problem into three parts: first, compute daily Likes-per-DAU for each country and post type using the provided DAU table; second, for each date, compute the median Likes-per-DAU for the same weekday over the prior 8 weeks, excluding outage dates; third, calculate the percent change from that median. Use window functions like PERCENTILE_CONT for the median and ensure proper filtering and partitioning.

Pro tip: Always verify that your DAU source is consistent with the metric definition—using the DailyActiveUsers table avoids double-counting and ensures alignment with company-wide standards. Also, consider edge cases like missing data or insufficient history for the 8-week median.

1. Calculate daily Likes-per-DAU

Join the likes table with DailyActiveUsers on date, country, and post type (if applicable) to compute Likes divided by DAU for each country, post type, and date. Ensure you use the provided DAU values, not a count of users.

2. Identify outage dates and filter

Exclude any dates flagged with an outage from the analysis. This ensures that anomalies due to outages do not skew the median calculation.

3. Compute rolling median for same weekday over prior 8 weeks

For each country, post type, and date, use a window function like PERCENTILE_CONT(0.5) to compute the median Likes-per-DAU over the same weekday in the prior 8 weeks, excluding outage dates. Ensure the window is correctly partitioned and ordered.

4. Calculate percent change

For each date, compute the percent change between the current Likes-per-DAU and the median from step 3. Handle cases where the median is zero or null to avoid division errors.

5. Validate and present results

Check for anomalies, ensure the output includes country, post type, date, Likes-per-DAU, median, and percent change. Consider aggregating or visualizing trends if needed.

Key Points to Mention

  • Use of PERCENTILE_CONT for median calculation with proper window partitioning and ordering.
  • Importance of excluding outage dates from both the current and historical data.
  • Correctly handling the 8-week lookback for same weekday (e.g., using date arithmetic to filter prior 8 weeks).
  • Joining with DailyActiveUsers table to get DAU instead of counting distinct users.
  • Handling edge cases: insufficient history, zero DAU, or null medians.
  • Ensuring the grain of the final output matches the request (country, post type, date).

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

Q2

Flag the top 3 countries with the largest percentage declines (at or below negative 10%) in Likes-per-DAU, and for each, break down how much of that decline comes from new users versus existing users. Return country, post type, percent change, and the share of decline attributable to new users.

Product Analytics & MetricsRoot Cause AnalysisA/B Testing & Experimentation
Author's notes

The attribution piece is what got me.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the metric definitions and data sources, then write a SQL query to compute Likes-per-DAU by country and post type, filtering for declines of at least 10%. For each flagged country, decompose the decline into new vs. existing user contributions using a weighted average or cohort-based analysis, and present the top 3 with the required fields.

Pro tip: Always validate your decomposition by checking that the sum of new and existing user contributions equals the total decline, and be prepared to explain any assumptions about user classification or time windows.

1. Clarify definitions and scope

Confirm what 'Likes-per-DAU' means (e.g., total likes divided by daily active users), how new vs. existing users are defined (e.g., first session in last 30 days), and the time period for comparison (e.g., week-over-week).

2. Compute metric and identify declines

Write a SQL query to calculate Likes-per-DAU for each country and post type over two periods, compute the percent change, and filter for declines at or below -10%.

3. Decompose decline by user type

For each flagged country, break down the total decline into contributions from new and existing users by calculating each group's Likes-per-DAU change and weighting by their share of DAU.

4. Rank and present top 3

Sort the flagged countries by percent decline, select the top 3, and for each, report country, post type, percent change, and the share of decline attributable to new users.

Key Points to Mention

  • Metric definition: Likes-per-DAU = total likes / daily active users, and ensure consistent aggregation across periods.
  • User segmentation: Define new users (e.g., first seen in last 30 days) vs. existing users, and note any edge cases like returning users.
  • Decomposition method: Use a weighted average approach where total change = (share_new * change_new) + (share_existing * change_existing).
  • Statistical significance: Consider if the decline is significant given sample sizes, especially for smaller countries.
  • Data quality: Check for missing data, outliers, or logging issues that could skew results.
  • Business context: Relate findings to potential product changes, seasonality, or external events that might explain the decline.

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

Q3

For the flagged countries, compute the friend request acceptance rate over the most recent 14-day window and compare it to the prior 14-day window. Return the absolute and relative change, and do this with window functions rather than correlated subqueries.

Product Analytics & MetricsRoot Cause AnalysisData Modeling
Author's notes

The 'no correlated subqueries' constraint is the real constraint here.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify the definition of acceptance rate and the flagged countries, then design a SQL query that aggregates daily friend requests and acceptances per country, uses window functions to compute rolling 14-day sums for the current and prior windows, and finally calculates absolute and relative changes. Ensure the query is efficient by avoiding correlated subqueries and leveraging window functions like SUM() OVER with ROWS BETWEEN.

Pro tip: Mention that you would validate the 14-day windows by checking for data completeness and edge cases like countries with zero requests in the prior window, and consider using a calendar table to handle missing dates.

1. Clarify requirements and definitions

Confirm what 'flagged countries' means, how acceptance rate is defined (e.g., accepted requests / total requests), and the exact date ranges for the two 14-day windows.

2. Aggregate daily metrics

Write a subquery or CTE that groups by country and date, summing total friend requests and accepted requests to get daily counts.

3. Compute rolling 14-day sums with window functions

Use SUM() OVER (PARTITION BY country ORDER BY date ROWS BETWEEN 13 PRECEDING AND CURRENT ROW) to calculate the 14-day rolling totals for requests and acceptances, then compute the acceptance rate for each day.

4. Compare current and prior windows

For each country, identify the most recent 14-day window and the prior 14-day window, then calculate the absolute change (current rate - prior rate) and relative change (absolute change / prior rate).

5. Handle edge cases and present results

Address scenarios like zero requests in the prior window (avoid division by zero) and ensure the output includes country, current rate, prior rate, absolute change, and relative change.

Key Points to Mention

  • Use of window functions (SUM OVER) to avoid correlated subqueries for performance.
  • Definition of acceptance rate as accepted requests divided by total requests.
  • Importance of partitioning by country and ordering by date.
  • Handling of missing dates or zero denominators to prevent errors.
  • Validation of the 14-day windows to ensure they are complete and consecutive.
  • Consideration of time zones and date boundaries if data is timestamped.

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

Q4

Walk through a pandas approach that mirrors the SQL logic above, covering groupby, merge, rolling or expanding windows, and quantile operations.

Product Analytics & MetricsData Modeling
Author's notes

Honestly a bit of a relief after the SQL gauntlet.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by restating the SQL logic in plain terms, then map each SQL clause to its pandas equivalent, emphasizing groupby, merge, rolling/expanding windows, and quantile operations. Walk through a concrete example with sample data, explaining how you would handle time-based windows and quantile calculations efficiently.

Pro tip: Mention that for rolling quantiles, pandas' rolling().quantile() can be slow on large datasets, so consider using expanding().quantile() or vectorized approaches like numpy's percentile with stride tricks for performance. Also, highlight the importance of sorting by time before rolling operations.

1. Clarify the SQL Logic

Restate the SQL query in plain English, identifying the grouping keys, join conditions, window frame (e.g., rolling 7-day), and quantile thresholds. This ensures alignment before diving into pandas.

2. Map GroupBy and Merge

Use df.groupby() to replicate GROUP BY, and pd.merge() for JOINs. Explain how to handle multiple keys and join types (inner, left, etc.) to mirror the SQL logic.

3. Implement Rolling or Expanding Windows

After sorting by time, use df.rolling(window=...) or df.expanding() to compute windowed aggregates. Discuss window types (time-based vs. count-based) and how to handle missing data.

4. Compute Quantiles

Apply .quantile(q) on the rolling/expanding object to get quantile values. For multiple quantiles, use a list and handle the resulting MultiIndex. Mention alternatives like numpy.percentile for performance.

5. Validate and Optimize

Compare results with the SQL output on a small dataset to ensure correctness. Discuss performance optimizations like using categorical dtypes, avoiding loops, and leveraging parallel processing if needed.

Key Points to Mention

  • GroupBy with multiple keys and aggregation functions
  • Merge types (inner, left, outer) and handling of duplicate column names
  • Rolling vs. expanding windows: time-based vs. count-based, min_periods parameter
  • Quantile calculation: interpolation methods, handling of NaN values
  • Performance considerations: vectorization, avoiding apply, using numpy for quantiles
  • Sorting by time before window operations to ensure correct order

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