문제
신고결과 받기
문제풀이
function solution(id_list, report, k) {
var answer = [];
var singo_list = {};
var set = new Set(report);
var id_list2 = {};
report = [...set];
for (var i = 0; i < report.length; i++) {
var key = report[i].split(' ')[1];
if (singo_list[key] == undefined) {
singo_list[key] = 1;
}
else {
singo_list[key] += 1;
}
}
for (var i = 0; i < id_list.length; i++) {
id_list2[id_list[i]] = 0;
}
for (var i = 0; i < report.length; i++) {
var keyword = report[i].split(' ')[1];
var singo_id = report[i].split(' ')[0];
var singo_cnt = singo_list[keyword];
if (singo_cnt >= k) {
id_list2[singo_id] += 1;
}
}
answer = Object.values(id_list2);
return answer;
}