Busiest Four-Hour Window Each Day for Instagram Photo Uploads
Last updated: November 29, 2026
Quick Overview
From hourly Instagram photo upload counts per region, find for each region and day the four consecutive hours with the most uploads, returning the window's start hour and its share of the day's uploads.
Meta
November 29, 20260
0
0 solved
From hourly Instagram photo upload counts per region, find for each region and day the four consecutive hours with the most uploads, returning the window's start hour and its share of the day's uploads.
Asked in Meta data engineering interviews tied to storage and media processing capacity, where the busiest window, not the daily total, sets how much transcoding capacity is needed. The interviewer checks forward-looking window frames, densifying hours, and the argmax-per-group pattern.
What the Interviewer Expects
- Densify the 24 hours of each region-day
- Use a frame of CURRENT ROW to 3 FOLLOWING
- Discard windows that run past the end of the day
- Pick the top window per region-day with a tie-break
- Report its share of the daily total
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
- Should windows be allowed to cross midnight? How would you change the query?
- How would you find the busiest 15-minute window from minute data?
- How does this feed a capacity plan with headroom?
- How would you compare the peak window across weeks?
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
upload_hourly(region, hour_ts, uploads) with UTC hours; hours with no uploads may be missing. Windows stay within a UTC day (hours 0 to 20 as start). I join to a 24-row hours_of_day(h) table so th...
Approach
Densify each region-day to 24 hours. A frame ROWS BETWEEN CURRENT ROW AND 3 FOLLOWING gives the four-hour sum starting at each hour; the last three hours of the day have short frames, so I count row...