You are viewing a single comment's thread. Return to all comments →
Same solution in Javascript
function minimumAbsoluteDifference(n, arr) { arr.sort((a, b) => a - b); let min = Math.abs(arr[0] - arr[1]), diff; for(let i = 2; i < n; i++) { diff = Math.abs(arr[i] - arr[i-1]); if(diff < min) { min = diff; } } return min; }
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 →
Same solution in Javascript