Friend Count Distribution and the Share of Users Below Fifty Friends
Last updated: November 29, 2026
Quick Overview
Compute every monthly active Facebook user's friend count (including users with zero friends), then use CUME_DIST to report the share of users at or below each friend count and the exact share below 50 friends.
Meta
November 29, 20260
0
0 solved
Compute every monthly active Facebook user's friend count (including users with zero friends), then use CUME_DIST to report the share of users at or below each friend count and the exact share below 50 friends.
Network density is a core Facebook health signal, and Meta analysts often describe it as a distribution rather than an average. The interviewer checks that zero-friend users are not lost, that both edge directions are counted, and that you know what CUME_DIST returns with ties.
What the Interviewer Expects
- Counts friends from both sides of the undirected friendship table
- Starts from the active user list so zero-friend users are included
- Uses CUME_DIST over friend count for the cumulative share
- Explains that tied values share the same CUME_DIST
- Answers the 'below 50' share precisely with strict inequality
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 compare this distribution between users who joined this year and older users?
- Would you rather report the median or the share below a threshold to leadership? Why?
- How would you compute this efficiently when the friendship table has hundreds of billions of rows?
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
Tables:
mau_users(user_id), users active in the last 28 days.friendships(user_low, user_high), one row per undirected pair.
I count all friends, active or not....
Approach
- Union both edge directions and count per user.
- Left join from
mau_userswithCOALESCE(count, 0). CUME_DIST() OVER (ORDER BY friend_count)is the fraction of users with a count less than...