## Merge them up

Points: 30
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type

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.

• commented on Feb. 22, 2023, 11:38 a.m.

is the given arrays sorted or not?

• commented on Feb. 23, 2023, 11:42 p.m.

yes

• commented on Jan. 31, 2021, 7:25 p.m. edit 2

edit It work small mistake

• commented on Jan. 17, 2021, 9:50 p.m.

Why i have TLE ?