[Solution] Array sorting CodeChef Solution | Codechef Solution 2022
You are given an unsorted permutation of size . An operation is defined as:
- Swap and for any in the range .
Find the maximum value of , such that, the permutation can be sorted by applying any finite number of operations.
👇👇👇👇👇
Note that, a permutation of size contains all integers from to 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 an integer , the size of permutation.
- The next line contains integers describing the permutation .
- It is guaranteed that the given permutation is not sorted.
Counting Words CodeChef Solution
MATH1 Enrolment CodeChef Solution
Group Assignment CodeChef Solution
Army Training CodeChef Solution
Sort the String CodeChef Solution
Vowel Anxiety CodeChef Solution
Array sorting CodeChef Solution
Output Format
For each test case, output on a new line the maximum possible value of .
Constraints
- Sum of over all test cases does not exceed
No comments:
Post a Comment