Published:
Updated:


Solution

import collections
import sys
from typing import List


def solution(strs: List[str], inspection_strs: List[str]) -> int:
    answer = 0

    strs_map = collections.defaultdict(str)

    for s in strs:
        strs_map[s] = 1

    for word in inspection_strs:
        if word in strs_map:
            answer += 1

    return answer


N, M = map(int, sys.stdin.readline().split())

N_array = []
for _ in range(N):
    N_array.append(sys.stdin.readline().rstrip())

M_array = []
for _ in range(M):
    M_array.append(sys.stdin.readline().rstrip())

print(solution(N_array, M_array))

Leave a comment