YouTube Most-Flagged Videos (Approved Only)
Problem
**[Asked at YouTube]**
Find the videos that were flagged by the **most distinct users**, considering
only flags where `is_approved = 1`.
If multiple videos tie at the maximum, return all of them.
Return `title` and `flag_count`, ordered by title.
Input data
Example rows — the live problem includes the full dataset.
flags
| flag_id | user_id | video_id | is_approved |
|---|---|---|---|
| 1 | 101 | 1 | 1 |
| 2 | 102 | 1 | 1 |
| 3 | 103 | 1 | 1 |
| 4 | 101 | 1 | 1 |
| 5 | 101 | 2 | 1 |
videos
| video_id | title |
|---|---|
| 1 | Cat Compilation |
| 2 | Dance Tutorial |
| 3 | Cooking Show |
| 4 | Travel Vlog |
Expected output
Your answer should return 1 row with the columns title, flag_count.
Starter code (Pandas (Python))
import pandas as pd
def most_flagged_videos(flags: pd.DataFrame, videos: pd.DataFrame) -> pd.DataFrame:
# Your code here
return flagsSolve this Pandas question free
Write Pandas (Python) and run it instantly in your browser — even on your phone. No signup needed to try.
Solution & explanation
Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.
Sign up free to unlock