Leetcode Problem 2456. Most Popular Video Creator

2456. Most Popular Video Creator

Leetcode Solutions

Using HashMaps to Track Popularity and Views

  1. Initialize a HashMap popularityMap to store the total views for each creator.
  2. Initialize a HashMap mostViewedMap to store the most viewed video ID and its view count for each creator.
  3. Iterate through the input arrays, updating both maps with the current video's information.
  4. Track the maximum popularity encountered during the iteration.
  5. After processing all videos, iterate through popularityMap to find all creators with the maximum popularity.
  6. For each such creator, retrieve their most viewed video ID from mostViewedMap, considering lexicographical order in case of ties.
  7. Compile the results into a list of lists, each containing a creator and their most viewed video ID.
  8. Return the compiled results.
UML Thumbnail

Brute Force with Sorting

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...