[PRO] 신고 결과 받기

천호영·2022년 4월 24일
0

알고리즘

목록 보기
10/100
post-thumbnail

출처: 2022 KAKAO BLIND RECRUITMENT
난이도: 프로그래머스 Lv1

def solution(id_list, report, k):
    report_set = set(report) # 여러번 신고를 하나로 처리하기 위해
    report_count_dict = {name: 0 for name in id_list} # 신고 횟수 카운트
    mail_count_dict = {name: 0 for name in id_list} # 메일 받을 횟수 카운트
    
    for one_report in report_set:
        from_id, to_id = one_report.split()
        report_count_dict[to_id]+=1
    
    # 정지당할 id들
    stop_id_list = [key for key,value in report_count_dict.items() if value >= k]
    
    for one_report in report_set:
        from_id, to_id = one_report.split()
        if to_id in stop_id_list:
            mail_count_dict[from_id]+=1
            
    return list(mail_count_dict.values())
profile
성장!

0개의 댓글