프로그래머스 - 2022 KAKAO BLIND RECRUITMENT - 신고 결과 받기
Coding Test

프로그래머스 - 2022 KAKAO BLIND RECRUITMENT - 신고 결과 받기

Indo Yoon

문제

https://programmers.co.kr/learn/courses/30/lessons/92334

정답

from collections import defaultdict

def solution(id_list, report, k):
    reports = defaultdict(list)
    counts = defaultdict(int)
    for reporter, reported in list(map(lambda x:x.split(), set(report))):
        reports[reporter].append(reported)
        counts[reported] += 1
    
    result = [0] * len(id_list)
    for idx, id in enumerate(id_list):
        for reported in reports[id]:
            if counts[reported] >= k:
                result[idx] += 1
        
    return result