Account
Draft saved on this device
▤ DescriptionOriginal CppValley problem
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

Arrays

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.

⌘ CodeC++17
GNU C++17 · main.cpp

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
Execution requires a secure external judge.