← Meta Interview Insights

Meta·Data Scientist·Technical Phone Screen·Intermediate

Intermediate
Jul 2026

Summary

Meta DS technical screen, two SQL problems back to back. Both were about querying a social platform's post and user tables, and the second one had a tricky percentage calculation that I almost set up wrong.

Questions Asked (2)

Q1

Given a posts table and a users table on a social platform, count the number of distinct users who authored at least one post that received 2 or more replies within 7 days of that post being created.

Product Analytics & MetricsData Modeling
Author's notes

I self-joined the posts table to pair parent posts with their replies, then filtered on the timestamp window.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the schema and define 'reply' as a post that references another post via a parent_post_id. Then, for each post, count replies within 7 days of its creation, filter to posts with at least 2 such replies, and finally count distinct authors of those posts.

Pro tip: Mention that you would confirm whether replies are stored in the same posts table (self-join) or a separate replies table, and discuss how to handle time zones and edge cases like exactly 7 days.

1. Clarify schema and definitions

Confirm the structure of the posts and users tables, and define what constitutes a 'reply' (e.g., a post with a parent_post_id). Also clarify the time window: 'within 7 days' likely means reply_created_at <= post_created_at + INTERVAL '7 days'.

2. Identify posts with ≥2 replies in 7 days

Write a subquery that joins the posts table to itself (or to a replies table) on the reply's parent_post_id = original post's post_id, filters replies created within 7 days of the original post, groups by original post, and counts distinct replies (or reply authors) having count >= 2.

3. Count distinct authors of qualifying posts

From the subquery result, select the distinct user_id (author) of the original posts and count them. Ensure you use COUNT(DISTINCT user_id) to avoid double-counting users who authored multiple qualifying posts.

4. Validate and discuss edge cases

Consider edge cases: replies by the original author, deleted posts, time zone differences, and whether 'within 7 days' includes the 7th day. Also, discuss performance implications and potential indexing strategies.

Key Points to Mention

  • Self-join on posts table using parent_post_id to identify replies.
  • Time window condition: reply_created_at <= post_created_at + INTERVAL '7 days'.
  • Use COUNT(DISTINCT user_id) to count unique authors.
  • Filter with HAVING COUNT(reply_id) >= 2 to get posts with at least 2 replies.
  • Consider whether replies are in the same table or a separate table.
  • Discuss handling of time zones and exact boundary of 7 days.

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

Q2

For users who received at least one reply to any of their posts, what percentage received replies from at least 2 distinct US-based users?

Product Analytics & MetricsData Modeling
Author's notes

The denominator is the part that almost got me.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the definitions of key terms (e.g., 'reply', 'US-based user', 'distinct') and the time frame. Then, outline a step-by-step SQL or data manipulation plan: identify users with at least one reply, count distinct US repliers per user, and compute the percentage of users with ≥2 distinct US repliers. Finally, discuss potential edge cases and validation.

Pro tip: Mention that you would confirm whether 'US-based' is determined by user profile location or IP address, as this can significantly affect the analysis. Also, consider if replies from the same user but different accounts count as distinct—clarify this with the interviewer.

1. Clarify Definitions and Scope

Ask clarifying questions to define 'reply', 'US-based user', 'distinct', and the time period. Confirm whether to include all posts or only certain types, and how to handle deleted users or posts.

2. Identify Users with At Least One Reply

Filter the dataset to include only users who have received at least one reply to any of their posts. This forms the denominator for the percentage calculation.

3. Count Distinct US Repliers per User

For each user in the filtered set, count the number of distinct US-based users who replied to their posts. Ensure that multiple replies from the same US user are counted only once.

4. Compute the Percentage

Calculate the percentage of users (from step 2) who have at least 2 distinct US repliers. This is done by dividing the count of such users by the total number of users with at least one reply, then multiplying by 100.

5. Validate and Discuss Edge Cases

Check for data quality issues, such as missing location data or duplicate replies. Discuss how to handle edge cases like users with no location info or replies from non-US users.

Key Points to Mention

  • Definition of 'reply': whether it includes comments, nested replies, or only direct replies to the original post.
  • Determination of 'US-based': using user profile country, IP address, or other signals, and how to handle missing or ambiguous data.
  • Distinctness: ensuring that multiple replies from the same US user are counted only once per post or across all posts.
  • Time frame: specifying the period for which replies are considered (e.g., all time, last 30 days).
  • Denominator: clearly defining the base population as users who received at least one reply, regardless of replier location.
  • SQL approach: using subqueries or CTEs to filter users, join with replies, and count distinct US repliers, then aggregate.

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