[Level1] 신고 결과 받기

Seokhun Yoon·2022년 5월 6일
0
post-thumbnail
function solution(id_list, report, k) {
    // 중복 제거
    let removeRepeat = [...new Set(report)].map(v=>v.split(" "))

    let reportedCounts = {} // 유저가 신고 당한 개수
    for (const el of removeRepeat) {
      reportedCounts[el[1]] = (reportedCounts[el[1]] || 0) + 1
    }

    // 유저가 받은 이메일 개수
    let mailCounts = {}
    for (const el of removeRepeat) {
      if(reportedCounts[el[1]] >= k) {
        mailCounts[el[0]] = (mailCounts[el[0]] || 0) + 1;
      }
    }

    let answer = id_list.map((id) => mailCounts[id] || 0)
    return answer;
}
profile
블록체인 개발자를 꿈꾸다

0개의 댓글