You are viewing a single comment's thread. Return to all comments →
Rust best solution If you’re looking for solutions to the 3-month preparation kit in either Python or Rust, you can find them below: my solutions
fn minimum_absolute_difference(arr: &[i32]) -> i32 { //Time complexity: O(n*log(n)) //Space complexity (ignoring input): O(n) let mut arr = arr.to_vec(); arr.sort_unstable(); let mut minimum_difference = (arr[0] - arr[1]).abs(); for index in 2..arr.len() { let difference = (arr[index] - arr[index - 1]).abs(); if minimum_difference > difference { minimum_difference = difference; }; } minimum_difference }
Seems like cookies are disabled on this browser, please enable them to open this website
Minimum Absolute Difference in an Array
You are viewing a single comment's thread. Return to all comments →
Rust best solution
If you’re looking for solutions to the 3-month preparation kit in either Python or Rust, you can find them below: my solutions