Error
|
|
---|---|
@Ibrahim Nash | 6379 |
@blackshadows | 6329 |
@mb1973 | 5376 |
@Quandray | 5231 |
@akhayrutdinov | 5111 |
@saiujwal13083 | 4510 |
@sanjay05 | 3762 |
@marius_valentin_dragoi | 3522 |
@sushant_a | 3459 |
@verma_ji | 3357 |
@KshamaGupta | 3318 |
Complete Leaderboard | |
|
|
@184025 | 104 |
@terabaap123 | 95 |
@arshjit_singh7 | 92 |
@anamikaprasad124 | 92 |
@kumsachin10 | 90 |
@vaibhavinayak | 75 |
@NullPointerException | 74 |
@ronaldo77 | 72 |
@TanmayJ | 70 |
@ritiksethi21 | 68 |
@bhupindersingh25122001 | 68 |
Complete Leaderboard |
Given two arrays: arr1[0..m-1] of size m and arr2[0..n-1] of size n. Task is to check whether arr2[] is a subset of arr1[] or not. Both the arrays can be both unsorted or sorted. It may be assumed that elements in both array are distinct.
Input:
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case contains an two integers m and n denoting the size of arr1 and arr2 respectively. The following two lines contains the space separated elements of arr1 and arr2 respectively.
Output:
Print "Yes"(without quotes) if arr2 is subset of arr1.
Print "No"(without quotes) if arr2 is not subset of arr1.
Constraints:
1 <= T <= 100
1 <= m,n <= 105
1 <= arr1[i], arr2[j] <= 105
Example:
Input:
3
6 4
11 1 13 21 3 7
11 3 7 1
6 3
1 2 3 4 5 6
1 2 4
5 3
10 5 2 23 19
19 5 3
Output:
Yes
Yes
No
Explanation:
Testcase 1: (11, 3, 7, 1) is a subset of first array.
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?
Yes