백준 알고리즘

백준 14425 파이썬

KokoaJelly 2023. 2. 20. 12:34

https://www.acmicpc.net/problem/14425

 

14425번: 문자열 집합

첫째 줄에 문자열의 개수 N과 M (1 ≤ N ≤ 10,000, 1 ≤ M ≤ 10,000)이 주어진다.  다음 N개의 줄에는 집합 S에 포함되어 있는 문자열들이 주어진다. 다음 M개의 줄에는 검사해야 하는 문자열들이 주어

www.acmicpc.net

import sys
input = sys.stdin.readline

N, M = map(int,input().split())
nums_data = set([input() for _ in range(N)])
count = 0
for _ in range(M):
    words = input()
    if words in nums_data:
        count += 1
print(count)

그렇게 어렵지는 않은 문제다. 

set을 잘 이용한다면, 풀 수 있는 문제