Testcase showing wrong answer

The output of the example is coming correct but when I submit it all test cases are showing wrong answer.
This is the code I have written.

for inputs where less than k swaps are possible your code is not running at all