You are viewing a single comment's thread. Return to all comments →
Java and O(n log n)
Collections.sort(arr); int minDiff = Integer.MAX_VALUE; for (int i = 1; i < arr.size(); i++) { int diff = Math.abs(arr.get(i) - arr.get(i - 1)); if (diff < minDiff) { minDiff = diff; } } return minDiff;
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 →
Java and O(n log n)