We’re preparing your current view and syncing the latest data.
Given an array of distinct integers, find all pairs of elements with the minimum absolute difference of any two elements. Return a list of pairs in ascending order (with respect to pairs), where each pair [a, b] satisfies a < b and the difference b - a is the minimum absolute difference among all pairs in the array.
An array of distinct integers.
A list of pairs of integers, where each pair represents two elements with the minimum absolute difference. The pairs should be sorted ascending by the first element, then second element.
2 <= arr.length <= 10^5; -10^6 <= arr[i] <= 10^6; All arr[i] are distinct.
Example 1
Input
[4,2,1,3]
Output
[[1,2],[2,3],[3,4]]
Explanation
After sorting the array, minimum absolute difference is 1. Pairs with difference 1 are (1,2), (2,3), and (3,4).