- Given an array arr[] of N distinct integers, check if this array is Sorted and Rotated clockwise.
A sorted array is not considered as sorted and rotated, i.e., there should be at least one rotation.
Note:-Array can be sorted both increasingly and decreasingly
Input
The first line of input contains number of testcases T. Each testcase contains 2 lines, the first line contains N, the number of elements in array, and second line contains N space separated elements of array.
Constraints:
1 <= T <= 50
3 <= N <= 10^3
1 <= A[i] <= 10^4
Output
Print “Yes” if the given array is sorted and rotated, else Print “No”, without Inverted commas.
Example
Sample Input:
2
4
3 4 1 2
3
1 3 2
Sample Output:
Yes
Yes
- Given an integer K, find a positive integer x such that K = x2 + 3*x. If no such positive integer x exists, print -1.
Input
First and the only line of the input contains an integer K.
Constraints:
1 <= K <= 1018
Output
Print a positive integer x such that the above equation satisfies. If no such integer x exists, print -1.