Algorithm/1일 1코테
[🥲 프로그래머스] 신고 결과 받기 (2022 KAKAO BLIND RECRUITMENT)
대인보우
2022. 2. 3. 14:57
반응형
신고 결과 받기
https://programmers.co.kr/learn/courses/30/lessons/92334?language=python3
오랜만에 코테....
몇개월 안풀었다고 다 까먹음 ㅎ^^
1단계지만 광탈했다!
유저가 신고한 사람들 중 k번 이상 신고당한 사람들을 추출하면 되는 문제!
# 다른 사람 풀이
# 다른 사람 코드 참고
def solution(id_list, report, k):
answer = [0] * len(id_list) # 답안
dic_report = {id: [] for id in id_list} # 해당 유저(key)를 신고한 ID 목록(value)
for i in set(report):
i = i.split()
dic_report[i[1]].append(i[0])
for key, value in dic_report.items():
if len(value) >= k: # 유저를 신고한 사람들이 k명이 넘으면
for j in value:
answer[id_list.index(j)] += 1
return answer
반응형