:)
[프로그래머스]신고 결과 받기, [프로그래머스]양궁대회 본문
https://school.programmers.co.kr/learn/courses/30/lessons/92334
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
구현
1. report에 대한 신고 유저, 신고 아이디 딕셔너리 만들기
2. Counter 함수로 신고 횟수 구하기
3. 신고 기준 횟수가 넘어가는 신고 아이디 리스트 만들기
4. 신고 아이디 리스트 포함 & 딕셔너리 value에 있는 개수 구해서 answer 리스트 만들기
from collections import Counter,defaultdict
def solution(id_list, report, k):
answer = []
dic = defaultdict(set)
report_count = Counter()
for r in report:
user_id, report_id = r.split()
dic[user_id].add(report_id)
for _, report_id in dic.items():
report_count.update(report_id)
singo = {x for x in report_count if report_count[x] >= k}
for id in id_list:
answer.append(len(dic[id] & singo))
return answer
https://school.programmers.co.kr/learn/courses/30/lessons/92342
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
'Algorithm(python)' 카테고리의 다른 글
[프로그래머스]주차 요금 계산 (1) | 2022.10.15 |
---|---|
[백준]겹치는 건 싫어, [백준]회전초밥 (0) | 2022.10.09 |
[프로그래머스]튜플, [프로그래머스]스킬트리 (0) | 2022.10.05 |
[백준]꽃길, [백준]도영이가 만든 맛있는 음식, [백준]부분 삼각 수열 (0) | 2022.10.05 |
[백준] 오리, [백준] 달력 (0) | 2022.09.28 |
Comments