일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 29 | 30 | 31 |
Tags
- counter
- sql
- AARRR
- join
- 조합
- python
- cte
- 완전탐색
- coding test
- lv4
- Queue
- time complexity
- 파이썬
- collections
- tableau
- lambda
- level4
- LeetCode
- Stack
- itertools
- 코딩
- 프로그래머스
- coding
- mysql
- import re
- Growth hacking
- 코딩테스트
- 코테
- programmers
- Level2
Archives
- 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()]

now me
On my github
728x90
'Coding Test > 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 |