Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- dict
- 운영체제
- level3
- programmers
- 다이나믹 프로그래밍
- MYSQL
- 그리디
- 재귀
- BOJ
- 백준
- 구현
- python
- BFS
- 브루트포스
- dfs
- DP
- 가상메모리
- 힙
- 가상메모리 관리
- 파이썬
- N과M
- 프로그래머스
- 다익스트라
- 수학
- 스택
- level2
- level0
- level1
- 코딩테스트
- 딕셔너리
Archives
- Today
- Total
동캄의 코딩도장
프로그래머스 level1 [추억 점수] 파이썬 본문
#프로그래머스 level1 추억 점수
from collections import defaultdict
def solution(name, yearning, photo):
answer = []
dic=defaultdict(int)
for i in range(len(name)):
dic[name[i]]=yearning[i]
for list_ in photo:
cnt=0
for name_ in list_:
cnt+=dic[name_]
answer.append(cnt)
return answer
딕셔너리를 이용하였다.
'코테 > 프로그래머스' 카테고리의 다른 글
프로그래머스 level2 [숫자 카드 나누기] 파이썬 (0) | 2023.06.07 |
---|---|
프로그래머스 level1 [명예의 전당 (1)] 파이썬 (0) | 2023.04.27 |
프로그래머스 level2 [순위 검색] 파이썬 (0) | 2023.04.17 |
프로그래머스 level2 [디펜스 게임] 파이썬 (0) | 2023.04.16 |
프로그래머스 level2 [연속된 부분 수열의 합] 파이썬 (0) | 2023.04.14 |