#K8206. Intersection of Two Arrays

    ID: 35891 Type: Default 1000ms 256MiB

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:

  1. An integer \(n\) representing the number of elements in the first array.
  2. A line with \(n\) space-separated integers representing the first array.
  3. An integer \(m\) representing the number of elements in the second array.
  4. 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.

## sample
5
1 2 3 4 5
5
4 3 2 1 0
1 2 3 4

</p>