You are viewing a single comment's thread. Return to all comments →
public static int minimumAbsoluteDifference(List<Integer> arr) { // Write your code here Collections.sort(arr); int minDiff = Integer.MAX_VALUE; for(int i =1; i < arr.size(); i++){ Integer temp = Math.abs(arr.get(i) - arr.get(i - 1)); if(temp < minDiff){ minDiff = temp; } } 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 →