#C3681. Intersection of Two Arrays
Intersection of Two Arrays
Intersection of Two Arrays
Given two arrays of non-negative integers, your task is to find the intersection of these two arrays. The intersection is defined as the set of elements that appear in both arrays. Each element in the result must be unique. The order of the output does not matter, but for the purpose of standardized output, you should output the result in ascending order.
Example 1:
Input: 1 2 2 1
and 2 2
Output: 2
Example 2:
Input: 4 9 5
and 9 4 9 8 4
Output: 4 9
Note: The input will be read from stdin and the output should be printed to stdout.
inputFormat
The input consists of two lines:
- The first line contains the elements of the first array separated by spaces. If the array is empty, the line will be empty.
- The second line contains the elements of the second array separated by spaces. If the array is empty, the line will be empty.
All numbers are non-negative integers.
outputFormat
Print a single line containing the unique common elements between the two arrays in ascending order, separated by a single space. If there is no intersection, print an empty line.
## sample1 2 2 1
2 2
2