|
| 1 | +packagecom.fishercoder.solutions; |
| 2 | + |
| 3 | +importjava.util.List; |
| 4 | + |
| 5 | +/** |
| 6 | + * 1200. Minimum Absolute Difference |
| 7 | + * |
| 8 | + * Given an array of distinct integers arr, find all pairs of elements with the minimum absolute difference of any two elements. |
| 9 | + * Return a list of pairs in ascending order(with respect to pairs), each pair [a, b] follows |
| 10 | + * a, b are from arr |
| 11 | + * a < b |
| 12 | + * b - a equals to the minimum absolute difference of any two elements in arr |
| 13 | + * |
| 14 | + * Example 1: |
| 15 | + * Input: arr = [4,2,1,3] |
| 16 | + * Output: [[1,2],[2,3],[3,4]] |
| 17 | + * Explanation: The minimum absolute difference is 1. List all pairs with difference equal to 1 in ascending order. |
| 18 | + * |
| 19 | + * Example 2: |
| 20 | + * Input: arr = [1,3,6,10,15] |
| 21 | + * Output: [[1,3]] |
| 22 | + * |
| 23 | + * Example 3: |
| 24 | + * Input: arr = [3,8,-10,23,19,-4,-14,27] |
| 25 | + * Output: [[-14,-10],[19,23],[23,27]] |
| 26 | + * |
| 27 | + * Constraints: |
| 28 | + * 2 <= arr.length <= 10^5 |
| 29 | + * -10^6 <= arr[i] <= 10^6 |
| 30 | + * */ |
| 31 | +publicclass_1200 { |
| 32 | +publicstaticclassSolution1 { |
| 33 | +publicList<List<Integer>>minimumAbsDifference(int[]arr) { |
| 34 | +returnnull; |
| 35 | + } |
| 36 | + } |
| 37 | +} |