1200. Minimum Absolute Difference Easy

@problem@discussion
#Array#Sorting



1/**
2 * [1200] Minimum Absolute Difference
3 *
4 * Given an array of distinct integers arr, find all pairs of elements with the minimum absolute difference of any two elements.
5 * Return a list of pairs in ascending order(with respect to pairs), each pair [a, b] follows
6 * 
7 * 	a, b are from arr
8 * 	a < b
9 * 	b - a equals to the minimum absolute difference of any two elements in arr
10 * 
11 *  
12 * Example 1:
13 * 
14 * Input: arr = [4,2,1,3]
15 * Output: [[1,2],[2,3],[3,4]]
16 * Explanation: The minimum absolute difference is 1. List all pairs with difference equal to 1 in ascending order.
17 * Example 2:
18 * 
19 * Input: arr = [1,3,6,10,15]
20 * Output: [[1,3]]
21 * 
22 * Example 3:
23 * 
24 * Input: arr = [3,8,-10,23,19,-4,-14,27]
25 * Output: [[-14,-10],[19,23],[23,27]]
26 * 
27 *  
28 * Constraints:
29 * 
30 * 	2 <= arr.length <= 10^5
31 * 	-10^6 <= arr[i] <= 10^6
32 * 
33 */
34pub struct Solution {}
35
36// problem: https://leetcode.com/problems/minimum-absolute-difference/
37// discuss: https://leetcode.com/problems/minimum-absolute-difference/discuss/?currentPage=1&orderBy=most_votes&query=
38
39// submission codes start here
40
41impl Solution {
42    pub fn minimum_abs_difference(arr: Vec<i32>) -> Vec<Vec<i32>> {
43        vec![]
44    }
45}
46
47// submission codes end
48
49#[cfg(test)]
50mod tests {
51    use super::*;
52
53    #[test]
54    fn test_1200() {
55    }
56}
57


Back
© 2025 bowen.ge All Rights Reserved.