백준 10816 숫자 카드 2

김민영·2023년 1월 1일
0

알고리즘

목록 보기
22/125
N = int(input())
N_lst = list(map(int, input().split()))

M = int(input())
M_lst = list(map(int, input().split()))

dict = {}
for i in M_lst:
    dict[i] = 0
    
for i in N_lst:
    try:
        dict[i] += 1
    except KeyError:
        continue

for i in M_lst:
    print(dict[i], end=" ")
  • 이진탐색으로 코드를 짜니 시간초과가 나온다.
  • 약간 꼼수 쓴 느낌으로.. 딕셔너리를 사용했다.
profile
노션에 1차 정리합니당 - https://cream-efraasia-f3c.notion.site/4fb02c0dc82e48358e67c61b7ce8ab36?v=

0개의 댓글