[Solution] End Sorted CodeChef Solution
Chef considers a permutation of End Sorted
if and only if and .
Chef is given a permutation .
In one operation Chef can choose any index and swap and . Determine the minimum number of operations required by Chef to make the permutation End Sorted
.
Note: An array is said to be a permutation of if contains each element of exactly once.
Input Format
- The first line of input will contain a single integer , denoting the number of test cases.
👇👇👇👇👇
- Each test case consists of two lines of input.
- The first line of each test case contains a single integer , denoting the length of the permutation .
- The second line contains space-separated integers , denoting the permutation .
Output Format
For each test case, output minimum number of operations required by Chef to make the permutation End Sorted
.
No comments:
Post a Comment