BETA

Difficulty Level: Basic

Submissions: 949 Accuracy:

32.56%

Shortest un-ordered subarray
     

Given an array of n distinct elements. Find the length of shortest unordered (neither increasing nor decreasing) sub array in given array.

Input:
The first line consists of an integer T i.e number of test cases. The first line of each test case consists of an integer n.The next line consists of n spaced numbers. 

Output:
Print the required output.

Constraints: 
1<=T<=100
1<=n<=100
1<=a[i]<=105

Example:
Input:

2
5
7 9 10 8 11
4
1 2 3 5

Output:
3
0

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Saksham Ashtputre

Set Default Code

					   
It is recommended to 'Compile & Test' your code before clicking 'Submit'!

Compilation/Execution Result:

Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.