Minimum Absolute Difference

Problem Given an array of distinct integers, find all pairs with the minimum absolute difference, returned in ascending order (each pair [a, b] with a < b).

Input / Output

  • Input: int array arr.
  • Output: list of pairs achieving the global minimum difference, sorted ascending.

Constraints

  • 2 <= n <= 10^5; values across a wide range — sorting dominates.

Example

  • arr = [4,2,1,3] → [[1,2],[2,3],[3,4]] (min diff 1).
asked …
LeaderboardSalaryAccount