You are viewing a single comment's thread. Return to all comments →
If sort is used properly, it does the work for us:
function minimumAbsoluteDifference(arr) { smallest = Infinity; arr.sort(function(a, b) { smallest = Math.min(smallest, Math.abs(a - b)); return a - b; }); return smallest; }
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 →
If sort is used properly, it does the work for us: