#K8206. Intersection of Two Arrays
Intersection of Two Arrays
Intersection of Two Arrays
Given two arrays of integers, compute the sorted list of the unique elements that appear in both arrays.
The task is to remove duplicates from each array, find their intersection, and return the result in sorted order. Use set operations or sorting techniques to simplify the process.
In mathematical terms, if \(A\) and \(B\) are the two arrays, you need to find \(A \cap B\), remove duplicates and output the sorted result.
inputFormat
The input is given via standard input (stdin) in the following format:
- An integer \(n\) representing the number of elements in the first array.
- A line with \(n\) space-separated integers representing the first array.
- An integer \(m\) representing the number of elements in the second array.
- A line with \(m\) space-separated integers representing the second array.
outputFormat
Output to standard output (stdout) a single line with the sorted unique intersection of the two arrays. The numbers should be separated by a single space. If there is no intersection, output an empty line.
## sample5
1 2 3 4 5
5
4 3 2 1 0
1 2 3 4
</p>