You are viewing a single comment's thread. Return to all comments →
JavaScript
function minimumAbsoluteDifference(arr) { arr.sort((a, b) => a - b); let currentMin = Math.abs(arr[0] - arr[1]); for (let i = 1; i < arr.length; i++) { let currentAbsDiff = Math.abs(arr[i] - arr[i + 1]); if (currentAbsDiff < currentMin) { currentMin = currentAbsDiff; } } return currentMin; }
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 →
JavaScript