Sort the Half Sorted
Submissions: 1988   Accuracy:

43.29%

  Difficulty: Basic   Marks: 1

Given an integer array of which both first half and second half are sorted. The task is to merge two sorted halves of the array into a single sorted array.

Input:
The first line of input contains an integer T denoting the number of test cases. Each test case contains an integer n which denotes the number of elements in the array a[]. Next line contains space separated n elements in the array a[].

Output:
Print the sorted array with space separated values.

Constraints:
1<=T<=100
1<=n<=103
-103<=a[i]<=103

Example:
Input:

2
6
2 3 8 -1 7 10
5
-4 6 9 -1 3
Output:
-1 2 3 7 8 10 
-4 -1 3 6 9 

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Shashwat Jain
Author: shashwat jain


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.