#K95202. Merge and Remove Duplicates
Merge and Remove Duplicates
Merge and Remove Duplicates
This problem requires you to merge two sorted arrays and remove duplicates. You are given two sorted arrays. Your task is to output a single sorted array that contains every unique element from both arrays.
You can use the formula: $$ merged = sorted(\, set(arr1) \cup set(arr2) \,) $$ to generate the final answer.
inputFormat
The input is read from standard input (stdin) and consists of four lines:
- The first line contains an integer \( n \), representing the number of elements in the first array.
- The second line contains \( n \) space-separated integers in non-decreasing order.
- The third line contains an integer \( m \), representing the number of elements in the second array.
- The fourth line contains \( m \) space-separated integers in non-decreasing order.
outputFormat
Output to standard output (stdout) a single line containing the merged sorted list with unique elements, with numbers separated by a single space. If the resulting array is empty, output nothing.
## sample5
1 3 4 5 7
4
2 3 5 6
1 2 3 4 5 6 7