Not able to find bug

Please help me find the bug. I have used greedy aproach that from starting index I am swapping if the no. at that index is not equal to desired no.

I came to know hat there is some mistake in statement