2456. Most Popular Video Creator Medium

@problem@discussion
#Array#Hash Table#String#Sorting#Heap (Priority Queue)



1/**
2 * [2456] Most Popular Video Creator
3 *
4 * 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 creator[i], has an id of ids[i], and has views[i] views.
5 * 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.
6 * 
7 * 	If multiple creators have the highest popularity, find all of them.
8 * 	If multiple videos have the highest view count for a creator, find the lexicographically smallest id.
9 * 
10 * Return a 2D array of strings answer where answer[i] = [creatori, idi] means that creatori has the highest popularity and idi is the id of their most popular video. The answer can be returned in any order.
11 *  
12 * <strong class="example">Example 1:
13 * 
14 * Input: creators = ["alice","bob","alice","chris"], ids = ["one","two","three","four"], views = [5,10,5,4]
15 * Output: [["alice","one"],["bob","two"]]
16 * Explanation:
17 * The popularity of alice is 5 + 5 = 10.
18 * The popularity of bob is 10.
19 * The popularity of chris is 4.
20 * alice and bob are the most popular creators.
21 * For bob, the video with the highest view count is "two".
22 * 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.
23 * 
24 * <strong class="example">Example 2:
25 * 
26 * Input: creators = ["alice","alice","alice"], ids = ["a","b","c"], views = [1,2,2]
27 * Output: [["alice","b"]]
28 * Explanation:
29 * The videos with id "b" and "c" have the highest view count.
30 * Since "b" is lexicographically smaller than "c", it is included in the answer.
31 * 
32 *  
33 * Constraints:
34 * 
35 * 	n == creators.length == ids.length == views.length
36 * 	1 <= n <= 10^5
37 * 	1 <= creators[i].length, ids[i].length <= 5
38 * 	creators[i] and ids[i] consist only of lowercase English letters.
39 * 	0 <= views[i] <= 10^5
40 * 
41 */
42pub struct Solution {}
43
44// problem: https://leetcode.com/problems/most-popular-video-creator/
45// discuss: https://leetcode.com/problems/most-popular-video-creator/discuss/?currentPage=1&orderBy=most_votes&query=
46
47// submission codes start here
48
49impl Solution {
50    pub fn most_popular_creator(creators: Vec<String>, ids: Vec<String>, views: Vec<i32>) -> Vec<Vec<String>> {
51        vec![]
52    }
53}
54
55// submission codes end
56
57#[cfg(test)]
58mod tests {
59    use super::*;
60
61    #[test]
62    fn test_2456() {
63    }
64}
65


Back
© 2025 bowen.ge All Rights Reserved.