#79Medium
Merge sorted arrays
Time: 1 s · Memory: 256 MB
- Arrays
Statement
You are given two arrays sorted in non-decreasing order: ( elements) and ( elements). Merge them into one array sorted in non-decreasing order.
Input format
The first line contains , the second line the array . The third line contains , the fourth line the array . , ; both arrays are sorted.
Output format
A single line with numbers — the merged array.
Examples
Input
5 0 2 4 6 8 5 1 3 5 7 9
Output
0 1 2 3 4 5 6 7 8 9
Input
3 1 1 2 2 1 3
Output
1 1 1 2 3
Note
The arrays are already sorted — there is no need to sort again. Use two pointers ( and ): on each step write the smaller of and and advance its pointer. When one array runs out, append the rest of the other.
