44. Set Operations
EasySet
Given two lists, print their union, intersection and difference (A − B), each sorted ascending on its own line. Print an empty line if a result is empty.
Input format
Line 1: elements of A Line 2: elements of B
Output format
Three lines: union, intersection, A − B.
Example 1
Input
1 2 3 4 3 4 5
Output
1 2 3 4 5 3 4 1 2
Example 2
Input
1 1 2 2 2 3
Output
1 2 3 2 1
Constraints
Up to 10⁴ integers per list
Read input from standard input and print the answer to standard output. Your code is judged against 4 test cases, most of them hidden.
Loading the MyLoginn IDE…