#C6136. Minimize Maximum Absolute Difference
Minimize Maximum Absolute Difference
Minimize Maximum Absolute Difference
You are given t test cases. In each test case, you are provided with an integer n followed by an array of n integers. Your task is to rearrange the array so that the maximum absolute difference between any two adjacent elements is minimized. Formally, if the rearranged array is a_1, a_2, \ldots, a_n, you want to minimize:
$$ \max_{1 \leq i < n} |a_{i+1} - a_i| $$
If there are multiple arrangements that achieve this, you must choose the lexicographically smallest one (i.e. the arrangement that would appear first if all valid arrangements were sorted in dictionary order).
Hint: Sorting the array in non-decreasing order yields a valid solution.
inputFormat
The input is read from standard input (stdin) in the following format:
- The first line contains an integer t, the number of test cases.
- For each test case:
- The first line contains an integer n, the size of the array.
- The second line contains n space-separated integers.
outputFormat
For each test case, output a single line containing the rearranged array. The numbers should be space-separated, and each test case's result should be printed on a new line to standard output (stdout).
## sample2
4
10 1 3 7
3
4 2 5
1 3 7 10
2 4 5
</p>