Nearly Sorted Algorithm

easy
1. You will be given an array and integer K 2. In the given array, elements can atmost be k positions afar from its actual position in a sorted array 3. Input is handled for you 4. It is a functional problem, please do not modify main()

Input Format

Input is handled for you.

Output Format

Print sorted array

Constraints

1<=N<=100

Notice

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

Example

Input
8
2
3 2 1 4 5 7 8 6
Output
1 2 3 4 5 6 7 8
Previous
Relative-sorting
Next
Rearrange An Array Such That Arr[i] = I

Related Questions