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