# ★★☆☆☆ 신고결과받기

# 구현코드

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;

public class Solution {
    public int[] solution(String[] id_list, String[] report, int k) {
        Map<String, HashSet<String>> reportMemberList = new HashMap<>();
        Map<String, Integer> getMailCount = new HashMap<>();
        for(String id : id_list){
            getMailCount.put(id,0);
            reportMemberList.put(id,new HashSet<>());
        }

        for(String rep : report){
            String[] checkReport = rep.split(" ");
            reportMemberList.get(checkReport[1]).add(checkReport[0]);
        }

       for(String key : reportMemberList.keySet()){
           HashSet<String> reporters = reportMemberList.get(key);
           if(reporters.size() >= k){
               for(String reporter : reporters){
                   Integer getMail = getMailCount.get(reporter);
                   getMailCount.put(reporter,getMail+1);
               }
           }
       }

       int[] answer = new int[id_list.length];
       for(int i = 0; i < answer.length; i++){
           answer[i] = getMailCount.get(id_list[i]);
       }
        return answer;
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35