728x90
https://www.acmicpc.net/problem/14425
메모리: 38,936 KB , 시간: 288 ms
사용 알고리즘: 자료 구조, 문자열, 집합과 맵, 해시를 사용한 집합과 맵, 트리를 사용한 집합과 맵
728x90
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws Exception{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
int N = Integer.parseInt(st.nextToken());
int M = Integer.parseInt(st.nextToken());
HashSet<String> S = new HashSet<>();
for (int i = 0; i < N; i++) {
S.add(br.readLine());
}
int result = 0;
String s;
for (int i = 0; i < M; i++) {
s = br.readLine();
if(S.contains(s)) result++;
}
System.out.println(result);
}
}728x90
'Problem Solving > BOJ' 카테고리의 다른 글
| [백준, BOJ 1717] 집합의 표현 (java) (0) | 2026.01.05 |
|---|---|
| [백준, BOJ 7682] 틱택토 (java) (0) | 2026.01.02 |
| [백준, BOJ 2166] 다각형의 면적 (java) (0) | 2025.12.10 |
| [백준, BOJ 16967] 배열 복원하기 (java) (0) | 2025.12.09 |
| [백준, BOJ 1072] 게임 (java) (0) | 2025.12.07 |