Count the minimum number of swaps needed to sort the array.
Asked in the OA stage. Count swaps between any two positions, not only adjacent positions. Return the minimum number of swaps needed to arrange an array of distinct integers in ascending order.
Implement min_swaps_to_sort(nums), where nums is a list of distinct integers. Return an integer. The input may be modified.
def min_swaps_to_sort(nums):