#K15186. Smallest Difference Challenge
Smallest Difference Challenge
Smallest Difference Challenge
You are given T test cases. Each test case contains an integer n followed by n integers. Your task is to sort the array and then find the smallest difference between any two adjacent elements in the sorted array.
Formally, if the sorted array is \(a_1, a_2, \ldots, a_n\), you need to compute the value:
\[ \min_{2 \le i \le n} (a_i - a_{i-1}) \]Output the computed smallest difference for each test case on a new line.
inputFormat
The input begins with an integer T denoting the number of test cases. For each test case:
- The first line contains an integer n — the number of elements in the array.
- The second line contains n space-separated integers.
Input is read from standard input (stdin).
outputFormat
For each test case, output a single line containing the smallest difference between any two adjacent elements in the sorted array. The output is written to standard output (stdout).
## sample2
5
4 2 1 5 3
3
10 1 8
1
2
</p>