What's Wrong in the code?

In UNLOCKS question, I have created a position array and solved the question. But only one test case is passing. Can someone point out mistake in the code.

@pswaldia1
You forgot to do k-- after performing swap

Oh! Silly Mistake. Thanks for your help.