You are viewing a single comment's thread. Return to all comments →
Here is my c++ solution, you can find the explanation here : https://youtu.be/6SnD7A1TbJQ
int minimumAbsoluteDifference(vector<int> arr) { sort(arr.begin(), arr.end()); int result = INT_MAX; for(int i = 1; i < arr.size(); i++){ int d = arr[i] - arr[i-1]; if( d < result) result = d; } return result; }
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 →
Here is my c++ solution, you can find the explanation here : https://youtu.be/6SnD7A1TbJQ