Notice
Recent Posts
Recent Comments
Link
관리 메뉴

one by one ◼◻◼◻

신고 결과 받기 (2022 KAKAO BLIND RECRUITMENT) 본문

코딩문제

신고 결과 받기 (2022 KAKAO BLIND RECRUITMENT)

JihyunLee 2022. 6. 6. 15:05

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from collections import defaultdict
 
def solution(id_list, report, k):
    singoed = set()
    answer = []
    singoed_cnt = defaultdict(int# 신고당한 횟수
    mail_cnt = defaultdict(int# 받은 메일의 수
    report = list(set(report))
    
    for item in report:
        person_A, person_B = item.split(" ")[0],item.split(" ")[1]
        singoed_cnt[person_B] +=1
        if singoed_cnt[person_B] >= k:
            singoed.add(person_B)
 
    for item in report:
        person_A, person_B = item.split(" ")[0],item.split(" ")[1]
        if person_B in singoed:
            mail_cnt[person_A] += 1
            
    for name in id_list:
        answer.append(mail_cnt[name])
    return answer
cs
Comments