You are viewing a single comment's thread. Return to all comments →
yes you are right
function minimumSwaps(arr) { let swap = 0; for (let i = 0; i < arr.length; i++) { while (i+1 !== arr[i]) { let temp = arr[arr[i] - 1]; arr[arr[i] - 1] = arr[i] arr[i] = temp; swap += 1; } } return swap; }
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 →
yes you are right