Programmers - 신고 결과 받기

SJ0000·2022년 5월 2일

문제 링크

각 ID별 신고자를 set에 저장 후(중복신고 제약조건), 정지 대상일 경우 신고자의 mail 수를 증가

def solution(id_list, report, k):
    # init
    answer = [0 for _ in range(len(id_list))]
    id_reports = dict()
    id_index = dict()
    index = 0
    for id in id_list:
        id_reports[id] = set()
        id_index[id] = index
        index += 1

    x = list(map(lambda x: x.split(), report))

    for [reporter, target] in list(map(lambda x: x.split(), report)):
        id_reports[target].add(reporter)

    for id, reports in id_reports.items():
        if len(reports) >= k:
            for reporter in reports:
                answer[id_index[reporter]] += 1

    return answer
profile
잘하고싶은사람

0개의 댓글