Draft saved on this device
▤ Description
Core C++Easy
Merge Two Sorted Vectors
Given two nondecreasing sequences A and B, merge them into one nondecreasing sequence.
Given two nondecreasing sequences A and B, merge them into one nondecreasing sequence. Duplicates are preserved. Use linear time in the total number of items.
Input format
First line N M; next N integers for A, then M integers for B.
Output format
Print the merged values space-separated on one line; print an empty line if both sequences are empty.
Examples
Example 1
Input
3 3 1 4 8 2 2 9
Expected output
1 2 2 4 8 9
Constraints
- 0 ≤ N,M ≤ 100000
- -10^9 ≤ values ≤ 10^9
- Both inputs are nondecreasing.
Related concepts
This early-access exercise uses standard input/output. More advanced concurrency challenges will use specialized class interfaces, instrumentation, and stress tests once the judging infrastructure is ready.
⌘ Code
Loading Monaco C++ editor…
Checking judge...
Checking whether the external C++ judge is available.
⌁ Test cases & resultsPublic samples: 1
Input
3 3 1 4 8 2 2 9
Expected output
1 2 2 4 8 9