Different Subarrays Rearrange CodeChef Solution | CodeChef Problem Solution 2022
You are given an array of integers . Determine if there are two permutations and of this array, for which the following condition is satisfied:
- There doesn't exist a pair of integers such that and , for which the subarray is a permutation of subarray .
If there exist such permutations, find any of them.
Solution Click Below:- CLICK HERE
As a reminder, refers to the subarray
Input Format
- The first line of the input contains a single integer , the number of test cases. The description of the test cases follows.
- The first line of each test case contains a single integer — the number of integers.
- The second line of each test case contains space-separated integers .
Output Format
For each test case, if there are no such permutations and , output NO
.
Otherwise, on the first line output YES
. In the next line, output integers . In the next line, output integers .
You may print each character of YES
/NO
in either uppercase or lowercase (for example, the strings YES
, yeS
, YeS
, and yEs
will all be treated as identical).
Constraints
- The sum of over all test cases doesn't exceed .
Sample Input 1
3
3
1 1 2
4
19 39 19 84
6
1 2 3 1 2 3
Sample Output 1
NO
YES
19 19 39 84
39 84 19 19
YES
1 1 2 2 3 3
2 3 3 1 1 2
Join Now for Solution:-
No comments:
Post a Comment