You are viewing a single comment's thread. Return to all comments →
static int minimumAbsoluteDifference(int[] arr) { int n = arr.Length; Array.Sort(arr); int minAbsDiff = Math.Abs(arr[0] - arr[1]); for(int i = 1; i < n - 1; i++){ int tempDiff = Math.Abs(arr[i] - arr[i + 1]); if(tempDiff < minAbsDiff) minAbsDiff = tempDiff; } return minAbsDiff; }
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 →
C# Code