Median Time From User Report to Moderation Action by Policy
Last updated: November 29, 2026
Quick Overview
Given a reports table (one row per user report on a video, with policy category) and a moderation_actions table, compute for each policy category the median minutes from a video's first report to its first moderation action, plus the share of reported videos that were actioned.
TikTok
November 29, 20260
0
0 solved
Given a reports table (one row per user report on a video, with policy category) and a moderation_actions table, compute for each policy category the median minutes from a video's first report to its first moderation action, plus the share of reported videos that were actioned.
TikTok's Trust and Safety org tracks how quickly reported content is reviewed, with tighter targets for categories like minor safety than for spam. The interviewer checks that you pick the right grain (video, not report), compute a median without relying on a vendor function, and keep unactioned videos visible.
What the Interviewer Expects
- Collapse many reports per video to the first report
- Use the first action at or after the first report
- Compute a median with ROW_NUMBER and counts, or PERCENTILE_CONT where available
- Report actioned share separately so the median does not hide backlog
- Explain why median beats mean for latency
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 add the 90th percentile and why might it matter more for minor safety?
- Some videos are actioned proactively before any report. How do you treat them?
- How would you show latency trends while the most recent reports are still pending?
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
reports(report_id, video_id, policy_category, reported_at): a viral video may get thousands of reports.moderation_actions(video_id, action, actioned_at): removals, age restrictions, and later...
Approach
- First report per video and category.
- First action per video.
- Join on video, keep actions at or after the first report, compute minutes.
- Median per category: rank rows, keep the middle one ...