Given 2 arrays A and B. You can apply the given operation on array A.
An operation on Array A is:
• Select an integer such that, 1 ≤ K S floor(N /2), where N is the size of the array
• Swap the prefix and suffix of length K of the array A.
• The prefix of an array of length K is the subarray of the array containing the first K elements in
the order arranged in the array.
• The suffix of an array of length K is the subarray of the array containing the last K element in the
order arranged in the array.
Check whether it is possible to convert Array A to Array B. If possible return 1, else -1.
unction description
omplete the function Solve which takes three parameters as arguments and returns 1 if A is
invertible to B is possible, else return -1.
Note: Use this input format if you are testing against custom input or writing code in a language where
we don't provide boilerplate code
The first line contains denoting the number of test cases.
For each test case:
Print 1 if it Is possible to convert Array A to Array B. If possible return 1, else -1.
Sample Input Sample Output
2 1
7 -1
1 2 4 9 3 5 6
2 3 1 9 6 4 5
4
1 2 3 4
2 3 1 4
Sample Input Sample Output
5 1
7 1
80 27 44 30 49 37 58 - 1
58 27 44 30 49 37 60 1
4 - 1
85 33 44 62
44 62 85 33
7
35 51 39 55 16 63 63
16 35 39 55 63 51 63
Given an array A containing N integers indexxed from 1 to N . A special value of a subarray that is available between index L and R (both inclusive) is equal to the following
MIN (AL , AL+1 , AL+2,...AN) = Σi=1R Ai
You are required performing Q operations that are of the following types :
Complete the find_magic_ value function. This function takes the following 4 parameter
array of answers to the queries:
Sample Input Sample Output
3 3 6 14
1 2 3
0 1 3
1 1 2
0 1 3
Sample input 1
18456 24680
147918 932777 512238 958787 919862 863274 520551
1 6119 17661
1 12614 16196
1 2186 9904
1 4928 6583
1 2212 16013
1 12883 15302
1 3505 12846
1 1249 11945
Sample output 1
1303783247522 1124314086382 65261880376 1553786582036