Minimum Absolute Difference in an Array

  • + 0 comments

    My rust solution:

    fn minimumAbsoluteDifference(arr: &mut [i32]) -> i32 {
        arr.sort();
    
        arr.windows(2)
            .map(|window| (window[0] - window[1]).abs())
            .min()
            .unwrap()