일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- 코딩
- counter
- lv4
- time complexity
- coding test
- CodingTest
- 연습문제
- Stack
- programmers
- join
- BFS
- Level2
- 데이터분석
- Queue
- coding
- level4
- 코테
- 프로그래머스
- itertools
- 코딩테스트
- import re
- lambda
- 조합
- collections
- 파이썬
- mysql
- 시간복잡도
- sql
- 완전탐색
- python
- Today
- Total
ror_coding
[Programmers] 신고 결과 받기 - 92334 본문
728x90
dictionary 선언에서 채우기.
Question
이용자의 ID가 담긴 문자열 배열 id_list, 각 이용자가 신고한 이용자의 ID 정보가 담긴 문자열 배열 report, 정지 기준이 되는 신고 횟수 k가 매개변수로 주어질 때, 각 유저별로 처리 결과 메일을 받은 횟수를 배열에 담아 return 하도록 solution 함수를 완성해주세요.
Code
def solution(id_list, report, k):
count = {i:0 for i in id_list}
result = {i:[] for i in id_list}
mail_count = {i:0 for i in id_list}
for i in set(report):
a, b = i.split(' ')
count[b] += 1 # 신고된 횟수.
result[b].append(a) # 신고한 사람들 저장.
for i,item in count.items():
if item >= k:
for j in result[i]: mail_count[j] += 1
return [i for i in mail_count.values()]
![](https://t1.daumcdn.net/keditor/emoticon/friends2/large/041.png)
now me
On my github
728x90
'Algorithm > Python' 카테고리의 다른 글
[Programmers] 점프와 순간 이동 - 12980 (0) | 2024.10.28 |
---|---|
[Programmers] 올바른 괄호 - 12909, 짝지어 제거하기 - 12973 (0) | 2024.10.28 |
[Programmers] 개인정보 수집 유효기간 - 150370 (1) | 2024.10.26 |
[Programmers] 바탕화면 정리 - 161990 (0) | 2024.10.26 |
[Programmers] 신규 아이디 추천 - 72410 (0) | 2024.10.25 |