IBMOA #6
Merge Two Sorted Arrays
Estimated EasyJudge-ready
Topics (AI-labelled)Two Pointers
Merge two non-decreasing arrays into one non-decreasing array, keeping all duplicate elements.
Input
The first line contains n, the second line contains the n items of a, and the third line contains the n items of b. The raw text of the same problem supplies the full ranges 2≤n≤100000, 0≤element≤10^9.
Output
Output the 2n items after merging.
Example 1
Input:
3
1 3 5
2 4 6
Output:
1 2 3 4 5 6
Example 2
Input:
2
1 1
1 1
Output:
1 1 1 1
Example 3
Input:
2
0 9
0 3
Output:
0 0 3 9
Example notes
The examples give 1 2 3 4 5 6; four 1s; and 0 0 3 9 respectively.
Editorial
Loading solution…