You are viewing a single comment's thread. Return to all comments →
def minimumSwaps(arr): i = 0 swap = 0 while i < len(arr): if arr[i] == i+1: i +=1 else: index = arr[i] -1 arr[i], arr[index] = arr[index], arr[i] 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 →