Question 1
You are given an array of distinct integers.
Your task is to:
Find the smallest absolute difference between any two elements in the array.
Print all pairs of numbers that have this smallest difference.
a. In each pair, the smaller number comes first.
b. Print the pairs in ascending order.
Example 1
Input:
n = 4 elements, and numbers = [6, 2, 4, 10]
Output:
2 4
4 6
Explanation:
The minimum absolute difference is 2, and the pairs with that difference are (2, 4) and (4, 6).
Example 2
Input:
n = 4 elements, and numbers = [4, -2, -1, 3]
Output:
-2 -1
3 4
Explanation:
The minimum absolute difference is 1, and the pairs with that difference are (-2, -1) and (3, 4).
Constraints
2 ≤ n ≤ 10⁵
-10⁹ ≤ numbers[i] ≤ 10⁹
Test Case Input Format
The first line contains an integer n.
The next n lines contain an integer element of numbers.