57. Merge Two Sorted Arrays
EasyTwo PointersMerge
Merge two sorted arrays into one sorted array.
Input format
Line 1: n Line 2: n sorted integers Line 3: m Line 4: m sorted integers (the line may be empty when m = 0)
Output format
The merged array.
Example 1
Input
3 1 4 7 4 2 3 8 9
Output
1 2 3 4 7 8 9
Example 2
Input
1 5 2 1 5
Output
1 5 5
Constraints
0 ≤ n, m ≤ 10⁵, n + m ≥ 1
Read input from standard input and print the answer to standard output. Your code is judged against 5 test cases, most of them hidden.
Loading the MyLoginn IDE…