Given 2 sorted arrays, return the intersection of both the arrays. The intersection of 2 arrays means all the elements which are present in both.
Array 1: [1, 3, 4, 5, 5, 6, 6, 7]
Array 2: [2, 5, 6, 6, 7, 8]
Intersection: [5, 6, 6, 7]
Note: The resultant array should also be sorted.
The first line contains an integer ‘T’ denoting the number of independent test cases.
For each test case, the input has three lines:
For each test case, print space-separated numbers denoting the intersection of the two sorted arrays.
3
4 4
1 2 3 4
1 3 4 5
4 5
1 1 3 3
3 3 4 5 6
8 6
1 3 4 5 5 6 6 7
2 5 6 6 7 8
1 3 4
3 3
5 6 6 7
1 <= T <= 100
1 <= n, m <= 104
1 <= Ai, Bi <= 105