package com.company;
import java.util.*;
class Solution {
static public void main(String[] args){
String[] id_list = {"con", "ryan"};
String[] reportList = {"ryan con", "ryan con", "ryan con", "ryan con"};
int k = 3;
System.out.println(Arrays.toString(solution(id_list, reportList, k)));
}
static public int[] solution(String[] id_list, String[] reportList, int reportNum) {
int[] answer = new int[id_list.length];
HashMap<String, HashSet<String>> reportMap = new HashMap<>();
HashMap<String, Integer> countMap = new HashMap<>();
for (String id : id_list) {
HashSet<String> reportingIdSet = new HashSet<>();
reportMap.put(id, reportingIdSet);
countMap.put(id, 0);
}
for (String report : reportList) {
String reporter = report.split(" ")[0];
String reportee = report.split(" ")[1];
reportMap.get(reportee).add(reporter);
}
for (String id : id_list) {
HashSet<String> reportingIdSet = reportMap.get(id);
if(reportingIdSet.size() >= reportNum){
for (String reportingId : reportingIdSet) {
int mailNum = countMap.get(reportingId);
countMap.put(reportingId, mailNum + 1);
}
}
}
for (int i = 0; i < id_list.length; i++) {
String id = id_list[i];
answer[i] = countMap.get(id);
}
return answer;
}
}