My soln - https://w...content-available-to-author-only...f.com/viewsolution/17946466</p>
My approach</p>
Assume 0- based indexing</p>
i= index of element</p>
(i-k-1>=0||i+k+1<n)==true then we can place i anywhere in array with index j satisfying (j-k-1>=0||j+k+1<n)==true. Andif this condition is false then we cannot move i anywhere.</p>
e.g. if we want to swap i with index j.</p>
Also abs(i-j)>k then we can swap them directly.</p>
Assume i<j </p>
if(j+k+1<n ==true) implies i+k+1<n is also true as i<j</p>
then we can swap i with n-1. i.e ai at index n-1, a[n-1] at i, aj at j </p>
Next swap j with n-1. now ai at j, a[n-1] at i, aj at n-1</p>
Next swap j with n-1. now ai at j, aj at i, a[n-1] at n-1</p>
</p>
If above condition is not true but i-k-1>=0 and j-k-1>=0</p>
then we can chose index 0 instead of n-1 and proceed as above to swap i,j</p>
So, Basically for all index i satisfying i-k-1>=0||i+k+1<n can be placed anywhere. And those which does not satisfy this condition cannot move.</p>
So we sort all elements excluding the index which does not satisfy this condition.</p>
prog.c:1:1: error: unknown type name ‘My’
My soln - https://www.codechef.com/viewsolution/17946466</p>
^~
prog.c:1:9: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘-’ token
My soln - https://www.codechef.com/viewsolution/17946466</p>
^