values. Find the smallest difference between any two of its elements and return every pair [a, b] with that difference, where a < b.
Order the pairs by a in ascending order.values=[10, 4, 7, 1] → [[1, 4], [4, 7], [7, 10]]
Sorted, this is [1, 4, 7, 10]: every neighbouring gap is 3, so all three pairs qualify.
values=[-5, 20, 0, 18] → [[18, 20]]
The smallest difference is 2, between 18 and 20.
values=[3, -2] → [[-2, 3]]
values are distinctvalues=[10, 4, 7, 1]
[[1, 4], [4, 7], [7, 10]]
Run checks the first 3 tests in your browser. Submit checks all 95 tests on the server, hidden ones included.