CPOD1 - Closest pairs in 1D V1
Given a array A of n integers (n > 1). Find the distance of the closest pair i.e. find the smallest value of |Ai-Aj| for i ≠ j.
Input
The first line of input consists of a single number t which determines the number of tests.
For each test case, the first line will be n and the second line will be n integers separated by spaces
Constraints
- 0 < t ≤ 10
- 1 < n ≤ 100000
- -2×109 ≤ Ai ≤ 2×109
Output
For each test case, print the distance of the closest pair.
Example
Input: 2
5
-2 -1 0 1 2
2
1 10 Output: 1
9
hide comments
Simes:
2023-02-13 14:22:03
Caution: some elements of A are outside the given range, but are in the range -2×10^10 ≤ Ai ≤ 2×10^10 |
Added by: | mlxa1997 |
Date: | 2019-01-20 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All |
Resource: | Self |