BETA

Difficulty Level: Basic

Submissions: 3652 Accuracy:

24.97%

Minimum distance between two numbers (Function Problem)
     

Given an array A[], of 'n' elements. Your task is to complete the function minDist which returns  an integer denoting the minimum distance between two integers x and y in the array. If no such distance is possible then return -1.
 

Input:
The first line of input contains an integer T, denoting the no of test cases. Then T test cases follow. Each test case consists of three lines. The first line of each test case contains an integer 'n' denoting size array. Then in the next line are 'n' space separated values of the array A[]. The last line of each test case contains two integers  x and y.


Output:
For each test case in a new line print the required answer .


Constraints:
1<=T<=100
1 <=n<= 100
1 <=A[], x, y<= 100


Example(To be used only for expected output):
Input:

2
2
1 2
1 2
7
86 39 90 67 84 66 62 
42 12
Output:
1
-1

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

Contributor: Saksham Raj Seth


					   
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.