You are viewing a single comment's thread. Return to all comments →
def minimumSwaps(arr): num_swap = 0 ordred = sorted(arr) for i in range(len(arr)): if arr == ordred: break if ordred[i] == arr[i]: continue else: j = arr.index(ordred[i]) arr[i], arr[j] = arr[j], arr[i] num_swap += 1 return num_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 →