Output is wrong for some test cases

I have tried to do a question on min swaps required to sort an array by recursion but the output is wrong for few test cases. A snippet of code is also attached.