10816 숫자 카드 2

장종민·2023년 9월 4일

boj

목록 보기
22/22


import sys
input = sys.stdin.readline

int(input())
n = list(map(int, input().split()))

int(input())
m = list(map(int, input().split()))

dic = dict()

for i in n:
    if i in dic:
        dic[i] += 1
    else:
        dic[i] = 1
    print(dic)


# m의 각 요소가 해시 key에 있다면 value를, 없다면 0을 출력 
print(' '.join(str(dic[j]) if j in dic else '0' for j in m))

해시라는 개념을 처음 알았다...
갈길이 멀다.

profile
비전공 오르미부트캠프 2기

0개의 댓글