Merge them up
Given two sorted arrays \(A\) and \(B\) of length up to \(10^{6}\) print the intersection of both arrays. The intersection of two arrays, is a sorted array that contains every element that occurs at least once in both arrays. see examples for more detail.
Input Specification
The first line contains two integers \(1 \leq N, M \leq 10^{6}\) the length of array \(A\) and length of array \(B\).
Second line contains \(N\) numbers \(1 \leq a_i \leq 10^{9}\).
Third line contains \(M\) numbers \(1 \leq b_i \leq 10^{9}\).
Output Specification
if the arrays have no elements in common print "Empty" without quotes otherwise print the sorted list of the intersection of the arrays.
Sample Input
1 2
1
4 7
Sample Output
Empty
Sample Input
4 3
1 2 2 3
2 3 5
Sample Output
2 3
Sample Input
4 4
1 2 2 3
1 2 2 5
Sample Output
1 2 2
Notes
The given arrays are sorted in non-decreasing order.
Comments
is the given arrays sorted or not?
yes
edit It work small mistake
Why i have TLE ?