forked from PSDaily/Algorithm-Study
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQ10816.java
More file actions
30 lines (26 loc) · 918 Bytes
/
Q10816.java
File metadata and controls
30 lines (26 loc) · 918 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package Baekjoon.algorithm.map_set;
import java.io.*;
import java.util.*;
public class Q10816 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readLine());
Map<Integer, Integer> card = new HashMap<>();
String[] cards = br.readLine().split(" ");
for(int i=0;i<N;i++){
int num = Integer.parseInt(cards[i]);
card.put(num,card.getOrDefault(num,0)+1);
}
int M = Integer.parseInt(br.readLine());
String[] nums = br.readLine().split(" ");
for(int i=0;i<M;i++){
int num = Integer.parseInt(nums[i]);
if(card.containsKey(num)){
System.out.print(card.get(num)+" ");
}
else{
System.out.print("0 ");
}
}
}
}