from collections import defaultdict
def solution(id_list, report, k):
answer = []
report = list(set(report))
report_cnt = defaultdict(int)
who_report = defaultdict(set)
for item in report:
user,report = item.split()
report_cnt[report] += 1
who_report[user].add(report)
for id in id_list:
cnt = 0
for user in who_report[id]:
if report_cnt[user] >= k:
cnt += 1
answer.append(cnt)
return answer
set으로 report 배열 중복을 제거하고
딕셔너리를 이용하여 문제 조건 반영하여 풀었다.