← 返回 microsoft 的题目列表Merge Two Sorted Arrays and Deduplicate
类型:online_judge
Given two integer arrays A and B sorted in non-decreasing order, merge them into a new array C such that:
C is still sorted in non-decreasing order;
C contains no duplicate values (global deduplication);
The input arrays must not be modified.
Input
Line 1: integer m (length of A)
Line 2: m integers (A)
Line 3: integer n (length of B)
Line 4: n integers (B)
Output
Print the deduplicated merged array C on one line, space-separated. Print an empty line if C is empty.
Constraints
0 <= m, n <= 2*10^5
Values fit in 32-bit signed integer range
Example
Input:
4
1 2 2 5
5
1 1 2 3 5
Output:
1 2 3 5
Example
Input
4
1 2 2 5
5
1 1 2 3 5
Output
1 2 3 5