#C13918. Find Differences in Two Lists
Find Differences in Two Lists
Find Differences in Two Lists
You are given two lists of integers. Your task is to compute three sets of numbers:
- common: numbers present in both lists.
- unique_to_list1: numbers that appear only in the first list.
- unique_to_list2: numbers that appear only in the second list.
Each of these lists should have no duplicates and must be sorted in ascending order. The final output should be a dictionary with the three keys exactly as shown.
For example, if the inputs are:
1 2 2 3 4 3 4 4 5 6
Then the output should be:
{'common': [3, 4], 'unique_to_list1': [1, 2], 'unique_to_list2': [5, 6]}
Note: If a list of integers is empty, the corresponding input line will be empty.
inputFormat
The input consists of two lines read from standard input:
- The first line contains space-separated integers representing the first list.
- The second line contains space-separated integers representing the second list. An empty line represents an empty list.
outputFormat
The output should be printed to standard output as a dictionary (in a similar style to Python's dictionary representation) with three keys: 'common'
, 'unique_to_list1'
, and 'unique_to_list2'
. The values corresponding to each key are lists of integers (sorted in ascending order and without duplicates).
1 2 2 3 4
3 4 4 5 6
{'common': [3, 4], 'unique_to_list1': [1, 2], 'unique_to_list2': [5, 6]}