You are viewing a single comment's thread. Return to all comments →
Similar python solution (just shorter code)
def minimumSwaps(arr): numSwaps = 0 i = 0 while(i < len(arr)-1): if arr[i] != i+1: tmp = arr[i] arr[i], arr[tmp-1] = arr[tmp-1], arr[i] numSwaps += 1 else: i += 1 return numSwaps
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 →
Similar python solution (just shorter code)