Average Facebook Gaming Session Minutes from Start and End Events
Last updated: November 29, 2026
Quick Overview
Facebook Gaming logs a start event and an end event for each play session, but some end events are missing. In pandas, pair each start with its end, drop unmatched starts and implausibly long sessions, and report average minutes per game.
Meta
November 29, 20260
0
0 solved
Facebook Gaming logs a start event and an end event for each play session, but some end events are missing. In pandas, pair each start with its end, drop unmatched starts and implausibly long sessions, and report average minutes per game.
A pandas pairing exercise in the style of Meta's online assessments for analytics roles, framed on instant and cloud games. The interviewer checks groupby with shift, sorting before pairing, and clear rules for broken data.
What the Interviewer Expects
- Sorts by user, game and time before pairing
- Uses groupby shift to look at the next event
- Keeps only start rows followed by an end
- Filters outliers with a stated cap
- Reports counts alongside averages
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 many sessions did you drop and how would you report that?
- How would you impute missing end events from heartbeats instead of dropping them?
- Why use a cap, and how would you pick its value?
- How would you get the median instead of the mean?
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
Columns: user_id, game_id, event (start or end), ts as a datetime. Rules: a start pairs with the next event for that user and game only if it is an end. Two starts in a row mean the first ...
Approach
Sort, then within each (user, game) group take shift(-1) of the event and timestamp. Keep start rows whose next event is an end, compute minutes, filter the cap, and aggregate by game....