[백준 문제풀이] 10816 - 숫자 카드 2
풀이
딕셔너리로 쉽게 풀이할 수 있다.
코드
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import sys
input = sys.stdin.readline
N = int(input())
numCard = list(map(int, input().split(" ")))
M = int(input())
myCard = list(map(int, input().split(" ")))
answer = {}
for i in myCard:
answer[i] = 0
for i in numCard:
if i in answer:
answer[i] += 1
for i in myCard:
print(f"{answer[i]} ", end="")
댓글남기기