LeetCode Problem

How to Solve Most Popular Video Creator

This problem requires summing the total views for each creator and identifying the video with the highest views for that creator. Use a hash table to accumulate views and track the top video per creator. Finally, extract all creators with maximum popularity and select their most viewed video, using lexicographical order when ties occur.

GhostInterview Help

Need help with Most Popular Video Creator without spending extra time grinding it?

GhostInterview can read Most Popular Video Creator from a screenshot, generate the answer path, explain the complexity, and support solver-first interview workflows when you need direct help fast.

Screenshot Input

Capture the prompt fast instead of rewriting the problem by hand.

Answer + Complexity

Get the solution path, trade-offs, and complexity summary in one pass.

Stealth Workflow

Stay outside captured layers on supported screen-share workflows.

Problem #2456Array scanning plus hash lookupReviewed 2026-03-08
Difficulty
Medium
Primary pattern
Array scanning plus hash lookup
Answer-first problem summary
Step-by-step approach and complexity
GhostInterview solver workflow

This problem requires summing the total views for each creator and identifying the video with the highest views for that creator. Use a hash table to accumulate views and track the top video per creator. Finally, extract all creators with maximum popularity and select their most viewed video, using lexicographical order when ties occur.

Problem Statement

You are given three arrays: creators, ids, and views, each of length n. Each entry represents a video where creators[i] is the creator's name, ids[i] is the video identifier, and views[i] is the view count. Videos may share ids, but each video is distinct with its own views.

Determine which creators have the highest total views summed across all their videos. For each top creator, return their name and the id of their video with the most views. If multiple videos tie in view count, choose the lexicographically smallest id. Return the results as an array of [creator, topVideoId] pairs.

Examples

Example 1

Input: creators = ["alice","bob","alice","chris"], ids = ["one","two","three","four"], views = [5,10,5,4]

Output: [["alice","one"],["bob","two"]]

The popularity of alice is 5 + 5 = 10. The popularity of bob is 10. The popularity of chris is 4. alice and bob are the most popular creators. For bob, the video with the highest view count is "two". For alice, the videos with the highest view count are "one" and "three". Since "one" is lexicographically smaller than "three", it is included in the answer.

Example 2

Input: creators = ["alice","alice","alice"], ids = ["a","b","c"], views = [1,2,2]

Output: [["alice","b"]]

The videos with id "b" and "c" have the highest view count. Since "b" is lexicographically smaller than "c", it is included in the answer.

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 only of lowercase English letters.
  • 0 <= views[i] <= 105

Solution Approach

Hash Table Accumulation

Scan through creators and views arrays while storing cumulative views per creator in a hash table. At the same time, track each creator's top-viewed video id to simplify tie-breaking later.

Determine Maximum Popularity

After accumulation, iterate through the hash table to identify the maximum total views among all creators. Keep a list of all creators matching this maximum popularity for the final result.

Select Top Video per Creator

For each creator with maximum popularity, select the video with the highest individual views. If multiple videos have equal views, return the lexicographically smallest id to ensure consistent output.

Complexity Analysis

MetricValue
TimeDepends on the final approach
SpaceDepends on the final approach

Time complexity is O(n) for scanning the arrays and populating the hash table. Space complexity is O(n) for storing cumulative views and top videos per creator. Sorting is avoided by lexicographical comparisons during accumulation.

What Interviewers Usually Probe

  • Checks if candidate uses hash tables for per-creator aggregation
  • Looks for proper handling of ties in video views using lexicographical order
  • Wants linear scanning without redundant sorting for performance

Common Pitfalls or Variants

Common pitfalls

  • Not handling multiple videos with same id correctly
  • Forgetting to compare video ids lexicographically in case of view ties
  • Using nested loops instead of hash table accumulation causing TLE on large n

Follow-up variants

  • Return only the single most popular creator instead of all ties
  • Include a threshold filter for minimum views to consider videos
  • Extend to top k creators by popularity instead of just the maximum

How GhostInterview Helps

  • Automatically highlights hash table plus array scanning approach for creators
  • Identifies edge cases like duplicate video ids and ties in views
  • Provides step-by-step accumulation and selection logic to avoid common pitfalls

Topic Pages

FAQ

The main pattern is array scanning combined with hash table lookup to accumulate views per creator efficiently.

How do I handle videos with the same view count?

Select the lexicographically smallest id among videos that tie for the highest views for a creator.

Can video ids repeat for different creators?

Yes, ids may repeat, but each video is distinct and counted individually in view totals.

What is the expected time complexity?

A single pass O(n) is expected using hash table accumulation; avoid nested loops to prevent TLE.

How does GhostInterview help solve this problem?

GhostInterview guides you through per-creator aggregation, top video selection, and handling tie-breaking efficiently.

GhostInterview Solver

Need direct help with Most Popular Video Creator instead of spending more time grinding it?

Download GhostInterview when you want a LeetCode solver, not another long practice loop. Capture Most Popular Video Creator from a screenshot, get the answer path and complexity, and use supported stealth workflows that stay outside captured layers.

Screenshot Input

Capture the prompt fast instead of rewriting the problem by hand.

Answer + Complexity

Get the solution path, trade-offs, and complexity summary in one pass.

Stealth Workflow

Stay outside captured layers on supported screen-share workflows.