Count Minimum-Difference Pairs
Problem statement
Given an array values of distinct integers, find the minimum absolute difference between any two values and return the number of unordered pairs that have that difference.
Function
countMinimumDifferencePairs(values: int[]) → intExamples
Example 1
values = [4,2,1,3]return = 3The minimum difference is 1, achieved by (1,2), (2,3), and (3,4).
Example 2
values = [1,5,9]return = 2Constraints
2 <= values.length <= 100000.- All values are distinct and fit in a signed 32-bit integer.