#K88027. Common Elements in Two Arrays
Common Elements in Two Arrays
Common Elements in Two Arrays
You are given two arrays of integers. Your task is to find the common elements between these two arrays, remove duplicates, and output them in sorted order. In other words, if the two arrays are \(A\) and \(B\), you need to compute the sorted list of elements in \(A \cap B\).
The input is read from standard input and the result should be printed to standard output. If there are no common elements, output an empty line.
Example:
Input: 5 1 3 4 6 7 4 3 5 6 9</p>Output: 3 6
inputFormat
The input consists of four lines:
- An integer \(n\) representing the number of elements in the first array.
- \(n\) space-separated integers representing the first array. If \(n=0\), this line will be empty.
- An integer \(m\) representing the number of elements in the second array.
- \(m\) space-separated integers representing the second array. If \(m=0\), this line will be empty.
outputFormat
Print the common elements (without duplicates) in sorted order on a single line, separated by a single space. If there are no common elements, print an empty line.
## sample5
1 3 4 6 7
4
3 5 6 9
3 6