Given an array of n elements, where each element is at most k away from its target position. The task is to print array in sorted form.
First line consists of T test cases. First line of every test case consists of two integers N and K, denoting number of elements in array and at most k positions away from its target position respectively. Second line of every test case consists of elements of array.
Single line output to print the sorted array.
2 1 3
2 6 3 12 56 8
1 2 3
2 3 6 8 12 56
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?Yes