java.lang.Object
g2401_2500.s2456_most_popular_video_creator.Solution

public class Solution extends Object
2456 - Most Popular Video Creator.<p>Medium</p> <p>You are given two string arrays <code>creators</code> and <code>ids</code>, and an integer array <code>views</code>, all of length <code>n</code>. The <code>i<sup>th</sup></code> video on a platform was created by <code>creator[i]</code>, has an id of <code>ids[i]</code>, and has <code>views[i]</code> views.</p> <p>The <strong>popularity</strong> of a creator is the <strong>sum</strong> of the number of views on <strong>all</strong> of the creator&rsquo;s videos. Find the creator with the <strong>highest</strong> popularity and the id of their <strong>most</strong> viewed video.</p> <ul> <li>If multiple creators have the highest popularity, find all of them.</li> <li>If multiple videos have the highest view count for a creator, find the lexicographically <strong>smallest</strong> id.</li> </ul> <p>Return <em>a 2D array of strings</em> <code>answer</code> <em>where</em> <code>answer[i] = [creator<sub>i</sub>, id<sub>i</sub>]</code> <em>means that</em> <code>creator<sub>i</sub></code> <em>has the <strong>highest</strong> popularity and</em> <code>id<sub>i</sub></code> <em>is the id of their most popular video.</em> The answer can be returned in any order.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> creators = [&ldquo;alice&rdquo;,&ldquo;bob&rdquo;,&ldquo;alice&rdquo;,&ldquo;chris&rdquo;], ids = [&ldquo;one&rdquo;,&ldquo;two&rdquo;,&ldquo;three&rdquo;,&ldquo;four&rdquo;], views = [5,10,5,4]</p> <p><strong>Output:</strong> [[&ldquo;alice&rdquo;,&ldquo;one&rdquo;],[&ldquo;bob&rdquo;,&ldquo;two&rdquo;]]</p> <p><strong>Explanation:</strong></p> <p>The popularity of alice is 5 + 5 = 10.</p> <p>The popularity of bob is 10.</p> <p>The popularity of chris is 4.</p> <p>alice and bob are the most popular creators.</p> <p>For bob, the video with the highest view count is &ldquo;two&rdquo;.</p> <p>For alice, the videos with the highest view count are &ldquo;one&rdquo; and &ldquo;three&rdquo;.</p> <p>Since &ldquo;one&rdquo; is lexicographically smaller than &ldquo;three&rdquo;, it is included in the answer.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> creators = [&ldquo;alice&rdquo;,&ldquo;alice&rdquo;,&ldquo;alice&rdquo;], ids = [&ldquo;a&rdquo;,&ldquo;b&rdquo;,&ldquo;c&rdquo;], views = [1,2,2]</p> <p><strong>Output:</strong> <a href="&quot;alice&quot;,&quot;b&quot;">&quot;alice&quot;,&quot;b&quot;</a></p> <p><strong>Explanation:</strong></p> <p>The videos with id &ldquo;b&rdquo; and &ldquo;c&rdquo; have the highest view count.</p> <p>Since &ldquo;b&rdquo; is lexicographically smaller than &ldquo;c&rdquo;, it is included in the answer.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>n == creators.length == ids.length == views.length</code></li> <li><code>1 <= n <= 10<sup>5</sup></code></li> <li><code>1 <= creators[i].length, ids[i].length <= 5</code></li> <li><code>creators[i]</code> and <code>ids[i]</code> consist only of lowercase English letters.</li> <li><code>0 <= views[i] <= 10<sup>5</sup></code></li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details