#C12688. Common Elements Finder
Common Elements Finder
Common Elements Finder
Given two lists of integers, your task is to find their common elements without duplicates and output them in ascending order. You must read input from standard input (stdin) and write your result to standard output (stdout).
The input consists of two lines:
- The first line contains space-separated integers representing the first list.
- The second line contains space-separated integers representing the second list.
The output should be a single line containing the sorted common elements separated by a single space. If no common elements exist, output an empty line.
Note: If any formula is referenced, it will be in \( \LaTeX \) format.
inputFormat
The input consists of two lines:
- The first line contains a space-separated list of integers (list1).
- The second line contains a space-separated list of integers (list2).
outputFormat
Output a single line containing the common elements between the two lists, sorted in ascending order and separated by a space. If there are no common elements, output an empty line.## sample
1 2 3 4 5
4 5 6 7 8
4 5