Merge Two Sorted Arrays

Easy

Given two sorted arrays A and B, find the merged sorted array C by merging A and B.

Example:
A: [1, 2, 3, 4, 4]
B: [2, 4, 5, 5]
C: [1, 2, 2, 3, 4, 4, 4, 5, 5]

Testing

Input Format

First-line contains an integer ‘T’ denoting the number of test cases.

For each test case the input has three lines:

  • Two space-separated integers ‘n’ and ‘m’ denoting the length of the array A and B respectively.
  • n space-separated integers denoting the elements of the array A.
  • m space-separated integers denoting the elements of the array B.

Output Format

For each test-case, the output has a line with n+m space separated integers denoting the elements of the array C.

Sample Input

2
5 2
1 3 3 4 4
5 6
6 2
1 3 3 3 3 4
9 11

Expected Output

1 3 3 4 4 5 6
1 3 3 3 3 4 9 11

Constraints

1 <= T <= 100
1 <= n, m <= 104
1 <= Ai, Bi <= 105

Editorial Link: Editorial