
Both the partitions need not be of the same size.
The first line of the input contains a single integer 'T', representing the number of test cases.
The first line of each test case consists of a single integer, representing the size of the array.
The second line of each test case contains 'N' space-separated integers, denoting the elements of the array.
For each test case, print the elements of the array in the space-separated form which is sorted in non-decreasing order.
You do not need to print anything. It has already been taken care of. Just implement the given function. Also, you need to update the given array in-place.
1 <= T <= 100
1 <= N <= 10^4
1 <= arr[i] <= 10^9
Time Limit: 1sec
A naive or brute force approach for this problem is to simply sort the entire given array, ignoring the fact that it consists of two already sorted partitions. We can use a quick sort or merge sort algorithm to sort the array efficiently. Also, most of the languages have their in-built sort methods which are quite efficient in terms of time and space complexities.
Follow the links below to get in-depth information about these algorithms-
Quick Sort - https://en.wikipedia.org/wiki/Quicksort
Merge Sort - https://en.wikipedia.org/wiki/Merge_sort
An efficient solution will be to use a modified version of merge() function used in the merge sort algorithm.