Given an array of N distinct elementsA[ ]. The task is to find the minimum number of swaps required to sort the array. Your are required to complete the function which returns an integer denoting the minimum number of swaps, required to sort the array.
The first line of input contains an integer T denoting the no of test cases . Then T test cases follow . Each test case contains an integer N denoting the no of element of the array A[ ]. In the next line are N space separated values of the array A[ ] .
For each test case in a new line output will be an integer denoting minimum umber of swaps that are required to sort the array.
1 <= T <= 100
1 <= N <= 103
1 <= A <= 104
User Task: Your task is to complete minSwaps() which should return number of swaps required to make the array elements sorted.
Example(To be used only for expected output):
4 3 2 1
1 5 4 3 2
Testcase 1: We need two swaps, swap 1 with 4 and 3 with 2 to make it sorted.