You are viewing a single comment's thread. Return to all comments →
The swapping using temp is not really required. You know that the value at a[t] should be a[i] and that the value at a[i] should be i+1.
so all you need is : a[t] = a[i] and a[i] = i+1
Seems like cookies are disabled on this browser, please enable them to open this website
Minimum Swaps 2
You are viewing a single comment's thread. Return to all comments →
The swapping using temp is not really required. You know that the value at a[t] should be a[i] and that the value at a[i] should be i+1.
so all you need is : a[t] = a[i] and a[i] = i+1