Detect Like Bursts Over a Sliding Sixty-Second Window
Last updated: November 29, 2026
Quick Overview
Given a likes DataFrame with user_id and like timestamp, compute for each user the maximum number of likes in any 60-second sliding window and flag users whose peak reaches a threshold, as a first-pass fake engagement signal.
TikTok
November 29, 20260
0
0 solved
Given a likes DataFrame with user_id and like timestamp, compute for each user the maximum number of likes in any 60-second sliding window and flag users whose peak reaches a threshold, as a first-pass fake engagement signal.
Like farms and automation scripts inflate engagement on TikTok videos, and integrity analysts often start with simple velocity rules before any model. This pandas question checks time-based rolling windows per group, recovering when the peak happened, and judgment about thresholds.
What the Interviewer Expects
- Use a time-based rolling window per user rather than a fixed row count
- Sort by user and time before rolling
- Return the peak count and its timestamp
- Explain window edge semantics (open left, closed right)
- Discuss false positives from heavy but genuine users
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 compute this in a streaming job with bounded memory per user?
- How would you combine velocity with diversity, for example likes spread across many unrelated creators?
- How would you pick the threshold without labeled data?
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
likes(user_id, like_ts), one row per like (unlikes already removed).- A burst is the maximum number of likes in any window of 60 seconds ending at a like.
- Threshold of 30 per minute as a starti...
Approach
groupby(user_id).rolling("60s") on a timestamp index gives, at each like, the count of that user's likes in (t - 60s, t]. The window only needs to be evaluated at like times, because the count can...