KEEP GOING
[python] 프로그래머스 92334번 : 신고 결과 받기 본문
반응형
https://programmers.co.kr/learn/courses/30/lessons/92334
구현
from collections import defaultdict
def solution(id_list, report, k):
# 중복 제거
report = list(set(report))
result = [0 for _ in range(len(id_list))]
# 고소 당한 사람의 고소 당한 횟수 카운트
accused = defaultdict(int)
for data in report:
p = data.split()[1]
accused[p] += 1
# 정지당한 사람들 리스트
paused = [key for key, v in accused.items() if v >= k]
# 정지당한 사람들을 고소한 사람들 횟수 증가
for data in report:
p1, p2 = data.split()
if p2 in paused:
idx = id_list.index(p1)
result[idx] += 1
return result
반응형
'code review > implementation' 카테고리의 다른 글
[python] 프로그래머스 12930번 : 이상한 문자 만들기 (0) | 2022.03.29 |
---|---|
[python] 3진법 뒤집기 (strip) (0) | 2022.03.18 |
[python] 프로그래머스 72410번 : 신규 아이디 추천 (isdigit(), isalpha()) (0) | 2022.03.17 |
[python] 프로그래머스 67256번 : 키패드 누르기 (divmod()) (0) | 2022.03.17 |
[python] 백준 6603번 : 로또 (combination, backtracking) (0) | 2022.02.25 |
Comments