Minimum swaps to sort array
Your task
Given an array a of distinct integers, return the minimum number of swaps (each swap exchanges any two positions) needed to sort the array in ascending order. The array length can be 1.
Examples
min_swaps_to_sort(a: list[int]) -> intExample 1
Input
min_swaps_to_sort([2, 1, 3, 4])Output
1