#C13343. Intersection of Two Lists
Intersection of Two Lists
Intersection of Two Lists
Given two lists of integers, your task is to compute the intersection of these two lists. In other words, find the set of numbers that appear in both lists. Formally, if A and B are two sets, then the intersection is given by \(A \cap B\). Note that each list may contain duplicates, but the output must contain each common number only once, sorted in ascending order. If there is no common element, output a single dash (-
).
inputFormat
The input is read from standard input (stdin) and consists of two lines:
- The first line contains space-separated integers representing the first list. It may be empty.
- The second line contains space-separated integers representing the second list. It may be empty.
outputFormat
Print to standard output (stdout) the distinct common integers in ascending order, separated by spaces. If there are no common elements, output a single dash (-
).
1 2 3
2 3 4
2 3