Problem Solving/Baekjoon
[백준] 13211 Passport Checking - Data Structure / Java
graycode
2023. 10. 31. 17:38
• 문제 링크
13211번: Passport Checking
The first line of the input contains an integer N. (1 ≤ N ≤ 100,000) The next N lines contains the list of N stolen passport numbers, one passport number per line. The next line of the input contains an integer M. (1 ≤ M ≤ 100,000) The next M lines
www.acmicpc.net
• 풀이 코드
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.HashSet;
import java.util.Set;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
Set<String> set = new HashSet<>();
int n = Integer.parseInt(br.readLine());
while (n-- > 0) set.add(br.readLine());
int m = Integer.parseInt(br.readLine()), cnt = 0;
while (m-- > 0) if (set.contains(br.readLine())) cnt++;
bw.write(String.valueOf(cnt));
bw.flush();
}
}