Union of Two Sorted Arrays
Given two sorted arrays, return their union containing only distinct elements, in sorted order.
Input format
The first line contains N and M. The second line contains N sorted integers, the third line M sorted integers.
Output format
Print the union (distinct elements of either array) in sorted order, space-separated.
Constraints
- Values fit in a 64-bit signed integer
- Trailing whitespace and a trailing newline are ignored by the judge
Read from stdin, write to stdout. Sample cases below show the exact format.
Sample cases
Example 1
Input
5 5
1 2 3 4 5
1 2 3 6 7Expected output
1 2 3 4 5 6 7Example 2
Input
3 2
1 1 2
2 2Expected output
1 2