Given an array of integers A of size N that is a permutation of [0, 1, 2, …, (N-1)].
It is allowed to swap any two elements (not necessarily consecutive).
Find the minimum number of swaps required to sort the array in ascending order.
The only argument given is the integer array A.
Return the minimum number of swaps.
1 <= N <= 100000 0 <= A[i] < N
Example Input 1: A = [1, 2, 3, 4, 0] Example Output 1: 4 Explanation: You cannot sort it with lesser swaps Example Input 2: A = [2, 0, 1, 3] Example Output 2: 2
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.