#C5312. Merge Two Lists Removing Duplicates
Merge Two Lists Removing Duplicates
Merge Two Lists Removing Duplicates
You are given two lists of integers. The first list contains n integers, and the second list contains m integers. Your task is to merge these two lists into one, preserving the order in which the integers appear (i.e. all elements of the first list come before the elements of the second list), and remove any duplicate values - only the first occurrence should be kept.
The input is read from standard input and the output should be written to standard output.
Note: If either list is empty, handle it accordingly.
inputFormat
The input consists of four lines:
- The first line contains an integer n, the number of integers in the first list.
- The second line contains n integers separated by spaces. If n is 0, this line may be empty.
- The third line contains an integer m, the number of integers in the second list.
- The fourth line contains m integers separated by spaces. If m is 0, this line may be empty.
outputFormat
Output a single line containing the merged list of integers with duplicates removed, in the order of their first occurrence. The integers should be separated by a single space.
## sample3
1 2 3
4
3 4 5 6
1 2 3 4 5 6
</p>