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
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.