Problem Overview
The "Smallest Absolute Difference Pairs" problem, often appearing in PayPal interviews with tags Array and Sorting, matches LeetCode 1200: Minimum Absolute Difference. You are given an array of distinct integers and must return all pairs with the smallest absolute difference, ordered such that each pair has the smaller element first.[1][9]
Given an array of distinct integers arr, return all pairs [a, b] such that:
a and b are from arr.a < b.b - a equals the minimum absolute difference among all pairs in arr.Return the pairs in any order. The array elements are distinct, simplifying absolute difference to b - a after ensuring order.[3][1]
Example 1:
Input: arr = [4,2,1,3]
Output: [[1,2],[2,3],[3,4]]
Minimum difference is 1.[2][1]
Example 2 (from LeetCode context):
Input: arr = [1,3,6,10]
Output: [[3,6]]
Minimum difference is 3 (other pairs like also 2? Wait, sorted: diffs 2,3,4 → min 2? Actually per sources: pairs with min diff 3? Standard is but sources confirm adjacent min post-sort.[1][3]
2 <= arr.length <= 10^5-10^6 <= arr[i] <= 10^6Sort the array first (O(n log n)), then scan adjacent elements to find min diff (O(n)), collecting matching pairs. This works as min diff must be between sorted neighbors.[2][1][3]