#K48642. Find Intersection of Two Integer Arrays
Find Intersection of Two Integer Arrays
Find Intersection of Two Integer Arrays
Given two arrays of integers, find the unique intersection of the two arrays. The result should contain the common elements between the two arrays, sorted in ascending order. Both arrays may contain duplicate values, but the output should list each common element only once.
For example, given the arrays [4, 9, 5] and [9, 4, 9, 8, 4], the unique intersection is [4, 9].
Note: If there are no common elements, print an empty line.
inputFormat
The input consists of two lines. The first line is a space-separated list of integers representing the first array. The second line is a space-separated list of integers representing the second array. If an array is empty, the corresponding line will be empty.
outputFormat
Output a space-separated list of integers that are present in both arrays, sorted in ascending order. If no common elements exist, output an empty line.
## sample4 9 5
9 4 9 8 4
4 9