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 video
  • ids[i] - the unique identifier of the i-th video
  • views[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"],["bob","two"]]
💡 Note: Alice has total views of 5+5=10, Bob has 10 views, Charlie has 4 views. Both Alice and Bob tie for highest total (10). Alice's best video is 'one' (both her videos have 5 views, 'one' < 'three' lexicographically). Bob's best video is 'two'.
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.

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

Visualization

Tap to expand
Most Popular Video Creator INPUT creators[] alice bob alice charlie ids[] one two three four views[] 5 10 5 4 Data Mapping: idx=0: alice, "one", 5 idx=1: bob, "two", 10 idx=2: alice, "three", 5 idx=3: charlie, "four", 4 ALGORITHM STEPS 1 Build Hash Maps totalViews + bestVideo per creator 2 Process Each Entry Add views, track best video ID Hash Table State: Creator Total BestVid alice 10 "one" bob 10 "two" charlie 4 "four" maxTotal = 10 3 Find Max Total Views alice=10, bob=10 (tie!) 4 Apply Tiebreaker "alice" < "bob" lexically alice's best: "one" < "three" FINAL RESULT Top Creator Found! Output: [["alice","one"]] alice has total views = 10 Best video: "one" (5 views) "one" < "three" lexically OK - Verified Key Insight: Use a HashMap to track both total views per creator AND their best video in one pass. For ties in views within a creator, choose lexicographically smallest video ID. Time: O(n) | Space: O(n) where n = number of videos TutorialsPoint - Most Popular Video Creator | Hash Map Approach
Asked in
Google 45 Amazon 38 Meta 32 Netflix 28
95.0K Views
Medium Frequency
~15 min Avg. Time
2.8K Likes
Ln 1, Col 1
Smart Actions
💡 Explanation
AI Ready
💡 Suggestion Tab to accept Esc to dismiss
// Output will appear here after running code
Code Editor Closed
Click the red button to reopen