Intersection of Two Arrays

Medium · rating 1300 · Hashing, Sorting

The first line has n and m. The second line has n integers, the third has m integers. Print the sorted, distinct values that appear in both, space-separated. If there are none, print an empty line.

Constraints: 1 ≤ n, m ≤ 105

Related problems

Open Intersection of Two Arrays in Code Arena →