나의 코드

from collections import Counter
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
data = [input() for _ in range(n)]
s = [input() for _ in range(m)]

count = 0
data = Counter(data)

for i in s:
    if data[i]:
        count += 1

print(count)

 

풀이 방법

Collections의 Counter를 이용

 

+ Recent posts