Practice Minimum Absolute Difference
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Given distinct integers arr, return all pairs [a,b] having the smallest absolute difference among any two input values. Require a < b within each pair and list the pairs in ascending order. Every pair must use values from arr.
Source: Minimum Absolute Difference on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
arr = [4,2,1,3]
Output
[[1,2],[2,3],[3,4]]
# Example 2
Input
arr = [1,3,6,10,15]
Output
[[1,3]]
# Example 3
Input
arr = [3,8,-10,23,19,-4,-14,27]
Output
[[-14,-10],[19,23],[23,27]]
Constraints
2 <= arr.length <= 10^5
-10^6 <= arr[i] <= 10^6
Related LeetCode Problems
Practice more problems similar to Minimum Absolute Difference.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.