forked from ndb796/python-for-coding-test
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path7.java
36 lines (30 loc) Β· 1001 Bytes
/
7.java
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
31
32
33
34
35
36
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// N(κ°κ²μ λΆν κ°μ)
int n = sc.nextInt();
// μ§ν©(Set) μ 보λ₯Ό μ²λ¦¬νκΈ° μν HashSet λΌμ΄λΈλ¬λ¦¬
HashSet<Integer> s = new HashSet<>();
for (int i = 0; i < n; i++) {
int x = sc.nextInt();
s.add(x);
}
// M(μλμ΄ νμΈ μμ²ν λΆν κ°μ)
int m = sc.nextInt();
int[] targets = new int[n];
for (int i = 0; i < m; i++) {
targets[i] = sc.nextInt();
}
// μλμ΄ νμΈ μμ²ν λΆν λ²νΈλ₯Ό νλμ© νμΈ
for (int i = 0; i < m; i++) {
// ν΄λΉ λΆνμ΄ μ‘΄μ¬νλμ§ νμΈ
if (s.contains(targets[i])) {
System.out.print("yes ");
}
else {
System.out.print("no ");
}
}
}
}