Minimum Absolute Difference Problem
Minimum Absolute Difference Problem — ExecCode Easy DSA Practice
Solve the Minimum Absolute Difference problem on ExecCode. Free online easy DSA practice in Two Pointers. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Description You are given an array of distinct integers arr, find all pairs of elements with the minimum absolute difference of any two elements. Your task is to compute the required answer and return a list of pairs in ascending order(with respect to pairs), each pair [a, b] follows. a, b are from arr - a < b - b - a equals to the minimum absolute difference of any two elements in arr.
Examples
Input {"nums": [4, 2, 1, 3]}; Output [[1,2],[2,3],[3,4]]
Constraints
2 <= arr.length <= 10^5 -10^6 <= arr[i] <= 10^6
Practice Minimum Absolute Difference free on ExecCode. Browse DSA problems, topic map, and placement guides.