Most Popular Video Creator - Problem
๐ฅ Most Popular Video Creator
You're working as a data analyst for a video streaming platform similar to YouTube. Your task is to identify the most popular content creators based on their total view counts across all their videos.
Given three arrays:
creators[i]- the name of the creator who made the i-th videoids[i]- the unique identifier of the i-th videoviews[i]- the number of views the i-th video has received
Your Goal: Find the creator(s) with the highest total popularity (sum of all their video views) and identify their most popular video.
Special Rules:
- If multiple creators tie for highest popularity, include all of them
- If a creator has multiple videos with the same highest view count, choose the one with the lexicographically smallest video ID
- Different videos can share the same ID (they're still considered separate videos)
Return a 2D array where each row contains [creator_name, most_popular_video_id] for each top creator.
Input & Output
example_1.py โ Basic Case
$
Input:
creators = ["alice","bob","alice","charlie"]
ids = ["one","two","three","four"]
views = [5,10,5,4]
โบ
Output:
[["alice","one"]]
๐ก Note:
Alice has total views of 5+5=10, Bob has 10 views, Charlie has 4 views. Alice has the highest total. Among Alice's videos, both have 5 views, but 'one' is lexicographically smaller than 'three'.
example_2.py โ Multiple Winners
$
Input:
creators = ["alice","alice","alice"]
ids = ["a","b","c"]
views = [1,2,2]
โบ
Output:
[["alice","b"]]
๐ก Note:
Alice is the only creator with total views of 5. Among her videos with max views (2), 'b' is lexicographically smaller than 'c'.
example_3.py โ Tie Breaker
$
Input:
creators = ["alice","bob","charlie"]
ids = ["video1","video2","video3"]
views = [10,10,10]
โบ
Output:
[["alice","video1"],["bob","video2"],["charlie","video3"]]
๐ก Note:
All creators have equal popularity (10 views each), so all are included in the result with their respective video IDs.
Visualization
Tap to expand
Understanding the Visualization
1
Initialize Tracking
Set up data structures to monitor creator performance metrics
2
Process Video Stream
As each video data arrives, update the creator's total views and check if it's their new best video
3
Update Leaderboard
Track the highest total popularity and identify leading creators
4
Generate Report
Compile final results showing top creators and their most successful videos
Key Takeaway
๐ฏ Key Insight: By processing the video stream once and maintaining running statistics, we can efficiently identify the most successful creators and their top-performing content in linear time.
Time & Space Complexity
Time Complexity
O(n)
Single pass through n videos, with constant time hash map operations
โ Linear Growth
Space Complexity
O(k)
Where k is the number of unique creators, for storing creator statistics
โ Linear Space
Constraints
- n == creators.length == ids.length == views.length
- 1 โค n โค 105
- 1 โค creators[i].length, ids[i].length โค 5
- creators[i] and ids[i] consist of lowercase English letters only
- 0 โค views[i] โค 105
๐ก
Explanation
AI Ready
๐ก Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code