
Select any subarray of length at most 'N' - 1 and rearrange the elements in any order.
Let 'N' = 5, 'A' = [1, 2, 3, 5, 4].
We can apply the operation to the subarray from index 4 to 5 (1-based indexing).
So our answer is 1.
First-line contains an integer 'T', which denotes the number of test cases.
For every test case:-
First-line contains an integer 'N', denoting the length of the array 'A'.
Second-line contains 'N' space-separated integers, elements of array 'A'.
For each test case, Return the minimum number of coins required to sort the permutation in increasing order.
You don’t need to print anything. Just implement the given function.
1 <= 'T' <= 10
3 <= 'N' <= 10^5
The Sum of 'N' overall test cases does not exceed 10^5.
Time Limit: 1 sec
Approach:-
Algorithm:-