#C5759. Intersection of Two Arrays

    ID: 49443 Type: Default 1000ms 256MiB

Intersection of Two Arrays

Intersection of Two Arrays

You are given two arrays of integers. Your task is to compute the intersection of these two arrays. The result should be a sorted list of unique integers that appear in both arrays.

Note: The input is provided via standard input (stdin) in two lines. Each line represents an array where the integers are separated by spaces. A line containing only whitespace represents an empty array.

The desired output is a single line listing the resulting integers in ascending order separated by spaces. If there are no common elements, output an empty line.

Example:

Input:
1 2 2 3
2 3 4 5

Output: 2 3

</p>

The mathematical interpretation of finding the intersection of two sets \(A\) and \(B\) can be expressed as follows:

\[ A \cap B = \{ x \mid x \in A \text{ and } x \in B \} \]

inputFormat

The input consists of two lines provided via standard input (stdin). Each line contains zero or more integers separated by spaces. A line that is empty or contains only whitespace represents an empty array.

For example:

1 2 2 3
2 3 4 5

outputFormat

Output a single line containing the sorted unique integers that are present in both arrays. The integers should be separated by a single space. If there is no common element, output an empty line.

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