User | Reported | Stopped |
muzi | “frodo”, “neo” | “frodo”, “neo” |
frodo | “neo” | “neo” |
apeach | “muzi”, “frodo” | “frodo” |
neo | null | null |
int[] result = new int[id_list.length];
HashMap<String, HashSet<String>> reportMap = new HashMap<>();
HashMap<String, Integer> reportCountMap = new HashMap<>();
for (int i = 0; i < id_list.length; i++) {
HashSet<String> reportId = new HashSet<>();
reportMap.put(id_list[i], reportId);
reportCountMap.put(id_list[i], 0);
}
Java
복사
초기화 단계
ReportMap | ReportCountMap |
muzi = [] | 0 |
frodo = [] | 0 |
apeach = [] | 0 |
neo = [] | 0 |
ReportMap(신고당한사람, 신고한사람)
for (String s : report) {
String reportId = s.split(" ")[0];
String reportedId = s.split(" ")[1];
reportMap.get(reportedId).add(reportId);
// 신고 당한 User = Key, 신고한 User = Value;
}
Java
복사
Report
[0] | [1] |
muzi | frodo |
apeach | frodo |
frodo | neo |
muzi | neo |
apeach | muzi |
ReportMap
(String s : report)
s = “muzi frodo”
ReportId = “muzi”
reportedId = “frodo”
reportMap.get(신고 당한 User).add(신고한 User)
reportMap.get(”frodo”).add(”muzi”)
for (String s : reportMap.keySet()) {
HashSet<String> sendEmail = reportMap.get(s);
if (sendEmail.size() >= k) {
for (String userId : sendEmail) {
reportCountMap.put(userId, reportCountMap.get(userId)+1);
}
}
}
Java
복사
ReportMap
Key | Value |
muzi | apeach |
frodo | muzi, apeach |
apeach | null |
neo | muzi, frodo |
S = frodo
Sendmail =muzi, apeach
if(sendemail.size ≥ 2){
for(String userId : sendEmail(=muzi, apeach)){
reportCountMap.put(muzi, .add(muzi)+1)
}
}
}
for (int i = 0; i < id_list.length; i++) {
result[i] = reportCountMap.get(id_list[i]);
}
return result;
Java
복사
idList
“muzi”, “frodo”
“apeach”, “neo”
result[0] = reportCountMap.get(”muzi”)
result[0] = 2
result[1] = reportCountMap.get(”frodo”)
result[1] = 1
..
result = [2, 1, 1, 0]