#K37827. Intersection of Two Arrays
Intersection of Two Arrays
Intersection of Two Arrays
Given two arrays of integers, compute their intersection (i.e., the common elements) without duplicates. The result should be returned in sorted ascending order.
The input is read from standard input (stdin) as two lines:
- The first line contains the first array's elements separated by spaces.
- The second line contains the second array's elements separated by spaces.
If a line is empty, it represents an empty array.
The output should be printed to standard output (stdout) as the sorted intersection numbers separated by spaces on a single line. If there is no intersection, print an empty line.
inputFormat
The input consists of two lines read from standard input:
- Line 1: Space-separated integers representing the first array. An empty line indicates an empty array.
- Line 2: Space-separated integers representing the second array. An empty line indicates an empty array.
outputFormat
Output the intersection of the two arrays in ascending order on a single line with each number separated by a space. If no common elements exist, print an empty line.
## sample1 2 2 1
2 2
2