← 返回 microsoft 的题目列表Minimum Absolute Difference Pairs
类型:online_judge
Given an integer array nums, find the minimum absolute difference min_diff between any two distinct elements, and return all pairs whose absolute difference equals min_diff.
Requirements:
Represent each pair as a length-2 list [a, b] with a < b.
Sort the resulting pairs by a ascending (and by b ascending if a ties).
Input
One line of integers representing nums (space-separated).
Output
Line 1: min_diff.
Line 2: all pairs in the format [[a1,b1],[a2,b2],...].
Constraints
2 <= len(nums) <= 2*10^5
-10^9 <= nums[i] <= 10^9
Example
Input:
-1 -2 -4 -5 7 10
Output:
1
[[-5,-4],[-2,-1]]
Example
Input
-1 -2 -4 -5 7 10
Output
1
[[-5, -4], [-2, -1]]