본문 바로가기
💻 하나씩 차곡차곡/프로그래머스 (Python)

[LV.1] 신고 결과 받기

by 뚜루리 2023. 3. 22.
728x90
320x100
import collections

def solution(id_list, report, k):
    answer = []

    # 중복 제거
    report = list(set(report))

    # 신고한사람 : 신고당한사람
    reportHash = collections.defaultdict(set)

    # 신고당한사람 : 신고당한횟수
    stopped = collections.defaultdict(int)

    for i in report:
        a, b = i.split(' ')
        reportHash[a].add(b)
        stopped[b] += 1

    for name in id_list:
        mail = 0
        for user in reportHash[name]:
            if stopped[user] >= k:
                mail += 1
        answer.append(mail)

    return answer
728x90
320x100