#K48517. Intersection of Two Arrays
Intersection of Two Arrays
Intersection of Two Arrays
Given two arrays of integers, your task is to compute their intersection, i.e. the set of common elements between the two arrays.
The result must not contain any duplicates. The input arrays are provided on two separate lines, each containing a space-separated list of integers. If an array is empty, its corresponding line will be empty.
The output should display the intersection elements in ascending order, separated by spaces. If there is no intersection, output an empty line.
The mathematical definition of the intersection of two sets \(A\) and \(B\) is:
\( A \cap B = \{ x : x \in A \text{ and } x \in B \} \)
inputFormat
The input consists of two lines:
- The first line contains a space-separated list of integers representing the first array.
- The second line contains a space-separated list of integers representing the second array.
Note: If an array is empty, the corresponding input line will be empty.
outputFormat
Output a single line containing the distinct intersection elements in ascending order separated by a single space. If the intersection is empty, output an empty line.
## sample1 2 2 1
2 2
2