Most Popular Video Creator

You are given two string arrays creators and ids, and an integer array views, all of length n. The i^th video on a platform was created by creators[i], has an id of ids[i], and has views[i] views.

The popularity of a creator is the sum of the number of views on all of the creator's videos. Find the creator with the highest popularity and the id of their most viewed video.

  • If multiple creators have the highest popularity, find all of them.
  • If multiple videos have the highest view count for a creator, find the lexicographically smallest id.

Note: It is possible for different videos to have the same id, meaning that ids do not uniquely identify a video. For example, two videos with the same ID are considered as distinct videos with their own viewcount.

Return a 2D array of strings answer where answer[i] = [creatorsi, idi] means that creatorsi has the highest popularity and idi is the id of their most popular video. The answer can be returned in any order.

Example 1
Inputcreators = ["alice","bob","alice","chris"], ids = ["one","two","three","four"], views = [5,10,5,4]
Output[["alice","one"],["bob","two"]]
Alice and bob both have popularity 10; bob's top video is "two", and alice's top tied videos are "one" and "three", so "one" is chosen because it is lexicographically smaller.
Example 2
Inputcreators = ["alice","alice","alice"], ids = ["a","b","c"], views = [1,2,2]
Output[["alice","b"]]
The videos with ids "b" and "c" have the highest view count, so "b" is included because it is lexicographically smaller.

Constraints

  • n == creators.length == ids.length == views.length
  • 1 <= n <= 10^5
  • 1 <= creators[i].length, ids[i].length <= 5
  • creators[i] and ids[i] consist only of lowercase English letters.
  • 0 <= views[i] <= 10^5

Asked at 1 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate