#C7216. Minimum Adjacent Difference
Minimum Adjacent Difference
Minimum Adjacent Difference
You are given an array of integers. Your task is to determine the minimum absolute difference between any two adjacent elements when the array is arranged in non-decreasing order.
Problem Statement: Given an array of n integers, sort the array in non-decreasing order and then compute the absolute differences between every pair of consecutive elements. Output the smallest of these differences.
Note: It is guaranteed that each test case contains at least two numbers.
Mathematical Formulation:
Let \(a_1, a_2, \dots, a_n\) be the integers in sorted order. Find \[ \min_{2 \leq i \leq n} \{a_i - a_{i-1}\} \]
inputFormat
The first line contains an integer \(T\) denoting the number of test cases. Each test case consists of two lines:
- The first line contains an integer \(N\) (the number of elements in the array).
- The second line contains \(N\) space-separated integers.
outputFormat
For each test case, output a single integer on a new line representing the minimum absolute difference between any two consecutive elements after sorting the array in non-decreasing order.
## sample5
3
1 3 6
4
4 10 1 7
4
5 9 1 4
4
10 20 40 80
5
1 2 3 4 5
2
3
1
10
1
</p>