Problem
Input format
The program reads from standard input, in this order: - a natural number `n`, followed by `n` integers representing the first array, sorted in non-decreasing order; - a natural number `m`, followed by `m` integers representing the second array, sorted in non-decreasing order. - `1 <= n, m <= 1000` - values are integers in the range `[-1000000, 1000000]` - the input arrays are already sorted in non-decreasing order (not necessarily strictly) - when both arrays contain equal values, the one from array `a` comes first
Output format
The program prints to standard output, on a single line, the `n + m` values resulting from the merge, separated by a single space, followed by a newline.
Example
5 1 3 5 7 9 4 2 4 6 8
1 2 3 4 5 6 7 8 9
Stuck?
Use the Get Hint button in the action bar to reveal a guided hint.
💬 Discussion
Loading...No comments yet. Be the first to start the discussion!
Sample cases (from the problem)
Sample Case 1
5 1 3 5 7 9 4 2 4 6 8
1 2 3 4 5 6 7 8 9
Solve it your way first
Community solutions unlock after you submit a passing solution. Don't peek.
Ready to solve this challenge?
Create a free account to write code, submit solutions, and track your progress.