---
# System prepended metadata

title: 2456. Most Popular Video Creator
tags: [Leetcode, Medium]

---

# 2456. Most Popular Video Creator
###### tags: `Leetcode` `Medium`
Link: https://leetcode.com/problems/most-popular-video-creator/description/
## 思路
记录下所有creator的所有影片的total view 放在```creatorViewCnt```里面
并且记录下total view的最大值
```creatorVideoIdx```记录的是这个creator所有影片里view最大的 如果有几个影片view一样大 记录字母顺序最小的影片id的**index**
## Code
```java=
class Solution {
    public List<List<String>> mostPopularCreator(String[] creators, String[] ids, int[] views) {
        long maxView = 0;
        Map<String, Long> creatorViewCnt = new HashMap<>();
        Map<String, Integer> creatorVideoIdx = new HashMap<>();
        int n = creators.length;
        for(int i=0; i<creators.length; i++){
            String creator = creators[i];
            String id = ids[i];
            int view = views[i];
            creatorViewCnt.put(creator, creatorViewCnt.getOrDefault(creator, 0L)+view);
            if(creatorViewCnt.get(creator)>maxView){
                maxView = creatorViewCnt.get(creator);
            }
            if(!creatorVideoIdx.containsKey(creator) || views[creatorVideoIdx.get(creator)]<view || (views[creatorVideoIdx.get(creator)]==view && ids[creatorVideoIdx.get(creator)].compareTo(id)>0)){
                creatorVideoIdx.put(creator, i);
            }
        }
        List<List<String>> ans = new ArrayList<>();
        for(String key:creatorViewCnt.keySet()){
            if(creatorViewCnt.get(key)==maxView){
                List<String> temp = new ArrayList<>();
                temp.add(key);
                temp.add(ids[creatorVideoIdx.get(key)]);
                ans.add(temp);
            }
        }
        return ans;
    }
}
```