#K57137. Find Common Elements in Two Lists
Find Common Elements in Two Lists
Find Common Elements in Two Lists
You are given two lists of integers. Your task is to find all the elements that are present in both lists. The resulting list should:
- Contain no duplicate elements.
- Be sorted in ascending order.
You must read the input from standard input (stdin) and write the output to standard output (stdout). The first line of input contains the elements of the first list separated by spaces. The second line contains the elements of the second list separated by spaces. If a list is empty, the corresponding input line will be empty.
For example:
Input: 4 9 5 9 4 9 8 4</p>Output: 4 9
Implement your solution according to these requirements.
inputFormat
The input consists of two lines:
- The first line contains a series of integers separated by spaces representing the first list.
- The second line contains a series of integers separated by spaces representing the second list.
Both lines may be empty, indicating an empty list.
outputFormat
Output a single line containing the common elements between the two lists, sorted in ascending order and separated by a single space. If there are no common elements, output an empty line.## sample
4 9 5
9 4 9 8 4
4 9
</p>