Hours From Publish to Peak Viewing Hour for Each Reel
Last updated: November 29, 2026
Quick Overview
Using hourly view counts for each Reel, compute how many hours after publishing each Reel hit its highest-view hour, then summarize the distribution of that time-to-peak by creator follower tier.
Meta
November 29, 20260
0
0 solved
Using hourly view counts for each Reel, compute how many hours after publishing each Reel hit its highest-view hour, then summarize the distribution of that time-to-peak by creator follower tier.
Comes up for data scientists on Reels distribution, where time-to-peak tells you how quickly ranking surfaces new content and how long a Reel stays fresh. The interviewer checks argmax per group with ties, timestamp differences, and a sensible summary at the end.
What the Interviewer Expects
- Find each Reel's peak hour with ROW_NUMBER
- Break ties toward the earliest hour
- Compute hours since publish with DATE_DIFF
- Restrict to Reels with a full observation window
- Summarize with percentiles by tier
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
- Why do you need to restrict to Reels published at least 7 days ago?
- How would you find Reels with a second peak later on?
- How would you define peak with a smoothed series instead?
- What does a shorter time-to-peak after a ranking change tell you?
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
reel_hourly_views(reel_id, hour_ts, views), rows only for hours with views; reels(reel_id, creator_id, published_at); creators(creator_id, follower_tier). I measure hours from `DATE_TRUNC('hour'...
Approach
Rank each Reel's hours by views descending, earliest hour first for ties, keep rank 1, and take the hour difference from publish. Then aggregate by tier with median and p90. Missing hours do not matte...