#K41137. Merge and Sort Plant Counts

    ID: 26799 Type: Default 1000ms 256MiB

Merge and Sort Plant Counts

Merge and Sort Plant Counts

You are given multiple test cases. In each test case, you are provided with two sorted arrays representing plant counts. Your task is to merge these two arrays into a single sorted array.

Formally, for each test case, given two sorted arrays \(A\) and \(B\), produce a sorted array \(C\) that contains all the elements from \(A\) and \(B\). Use the two-pointer technique to achieve an efficient solution in \(O(n+m)\) time for each test case.

Good luck and happy coding!

inputFormat

The input begins with an integer \(T\) representing the number of test cases.

  • For each test case:
    • The first line contains two integers \(n\) and \(m\) which are the sizes of the two sorted arrays.
    • The second line contains \(n\) space-separated integers representing the first sorted array.
    • The third line contains \(m\) space-separated integers representing the second sorted array. This line may be empty if \(m = 0\).

outputFormat

For each test case, output a single line that contains the merged sorted array. The numbers should be separated by a single space.

## sample
1
3 3
1 3 5
2 4 6
1 2 3 4 5 6

</p>