#C14761. List Intersection
List Intersection
List Intersection
Given two lists of integers, your task is to compute the unique intersection of these two lists. The intersecting elements should be printed in ascending order separated by a single space. If the two lists have no common elements, output an empty line.
Input is read from standard input (stdin) and output should be written to standard output (stdout).
Note: Each list may contain duplicate elements, but the intersection should include each common element only once.
inputFormat
The input consists of four lines:
- The first line contains an integer n, the number of elements in the first list.
- The second line contains n space-separated integers representing the first list.
- The third line contains an integer m, the number of elements in the second list.
- The fourth line contains m space-separated integers representing the second list.
If n or m is 0, the corresponding list will be empty.
outputFormat
Output a single line containing the intersection of the two lists. The result should contain the unique common elements in ascending order, separated by a single space. If there are no common elements, output an empty line.
## sample5
1 2 3 4 5
5
3 4 5 6 7
3 4 5
</p>