You are viewing a single comment's thread. Return to all comments →
for (int i = 0; i < arr.length - 1; i++) { if (i < arr[i] - 1) { swap(arr, i, Math.min(arr.length - 1, arr[i] - 1)); minSwaps++; i--; } }
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 →