-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirstAtCoder.java
More file actions
42 lines (30 loc) · 901 Bytes
/
firstAtCoder.java
File metadata and controls
42 lines (30 loc) · 901 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
31
32
33
34
35
36
37
38
39
40
41
42
package test;
import java.util.*;
public class firstAtCoder {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int t = s.nextInt();
s.nextLine();
while(t-- > 0) {
int m = s.nextInt();
int n = s.nextInt();
Boolean ans = false;
int arr1[] = new int[m];
ArrayList<Integer> arr2= new ArrayList<Integer>();
for(int i =0;i<m;i++)
arr1[i] = s.nextInt();
for(int i =0;i<n;i++)
arr2.add(s.nextInt());
HashMap <Integer,Integer> hash= new HashMap<Integer,Integer>();
for(int i = 0;i<m;i++){
if(arr2.contains(arr1[i]))
hash.put(arr1[i],i);
if(hash.keySet().size() == n){
ans = true;
break;
}
}
System.out.println(ans?"Yes":"No");
}
}
}