Distribution of Daily Sessions per User on Facebook Lite
Last updated: November 29, 2026
Quick Overview
Using a sessions table for Facebook Lite, build a histogram of how many sessions each active user had yesterday, with buckets 1, 2, 3 to 5, 6 to 10 and more than 10, and the share of users in each bucket.
Meta
November 29, 20260
0
0 solved
Using a sessions table for Facebook Lite, build a histogram of how many sessions each active user had yesterday, with buckets 1, 2, 3 to 5, 6 to 10 and more than 10, and the share of users in each bucket.
A two-level aggregation warm-up typical of Meta's data science technical screen, framed on Facebook Lite in emerging markets. The interviewer checks that you aggregate per user first, bucket second, and compute shares with a window over the grouped result.
What the Interviewer Expects
- Aggregates sessions per user before bucketing
- Uses a CASE expression to build ordered buckets
- Computes shares with a window sum over grouped counts
- Orders buckets logically, not alphabetically
- Restricts to yesterday on the partition column
Key Topics to Cover
How to Approach This
- Clarify the schema and expected output format before writing queries.
- Use CTEs (WITH clauses) to break complex queries into readable steps.
- Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
- Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
- For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
- How would you show the same histogram split by network type (2G, 3G, Wi-Fi)?
- Why might Facebook Lite users show more, shorter sessions than the main app?
- How would you turn the histogram into a CDF?
- What would make the 'more than 10' bucket suspicious?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice SQL ProblemsSample Answer
Clarify the Data
lite_sessions(user_id, session_id, ds, duration_s) with ds as the date partition. Active means at least one session yesterday, so there is no zero bucket. Buckets: 1, 2, 3-5, 6-10, 11+....
Approach
Count sessions per user for yesterday, map each count to a bucket label plus a sort key, then count users per bucket. The share is the bucket count over the total, computed with `SUM(COUNT(*)) OVER ()...