You are given an array consisting of N integers. Your task is to sort the array in non-descending order using merge sort. Perform the task as in-place.
Note:
In-place means that your implementation does not require extra memory for merge operation, unlike the standard implementation.
Example:
Let the array be [1, 2, -3, 4, -4, -5]. On sorting the array in non-descending order we get the resulting array [-5, -4, -3, 1, 2, 4].
Input format:
The very first line of input contains an integer ‘T’ denoting the number of test cases.
The first line of every test case contains an integer ‘N’ denoting the number of elements present in the array.
The second line of every test case contains ‘N’ space-separated integers denoting the elements present in the array.
Output format:
For each test case, the resulting sorted array is printed.
Output for each test case is printed on a separate line.
Note:
You do not need to print anything, it has already been taken care of. Just return the sorted array.
Constraints:
1 <= T <= 10
1 <= N <= 5000
-10^5 <= Arr[i] <= 10^5
Where ‘T’ represents the number of test cases and ‘N’ represents the number of elements present in the array.
Time Limit: 1 sec