There are N competitors in an exam .Each competitor has his own skill value which is given by the array s=s1,s2,....sN where s1 is the skill of the first competitor,s2 is the skill of second competitor and so on.. Two competitors are said to be tough competitors if their skill difference is least i.e. they are very close in their skill values.Given N and an array s as input,find the tough competitors among the N competitors and print the absolute of the difference of their skill values.
First line of the input contains an integer T denoting the number of test cases. Then T test cases follow. First line of every test case consists of an integer N, denoting number of competitors. Second line of every test case consists of N spaced separated integers, denoting the skill values of the competitors.
Corresponding to each test case, print the difference of the skill values of the tough competitors in a new line.
9 4 12 6
4 9 1 32 12
In the first case |9-4|=5 ,|9-12|=3,|9-6|=3,|4-12|=8,|4-6|=2,|12-6|=6 so,the tough competitors are competitors having skill values 4,6 having their skill difference as 2.
In the second case tough competitors are competitors having skill values (4,1) and (9,12) having their skill difference as 3.
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.