You are viewing a single comment's thread. Return to all comments →
public static void miniMaxSum(List<Integer> arr) { // Write your code here long totalSum = 0; int minNumber = Integer.MAX_VALUE; int maxValue = Integer.MIN_VALUE; for (Integer integer : arr) { minNumber = Math.min(minNumber , integer); maxValue = Math.max(maxValue, integer); totalSum += integer; } System.out.print(totalSum - maxValue + " "); System.out.println(totalSum - minNumber); }
Seems like cookies are disabled on this browser, please enable them to open this website
Mini-Max Sum
You are viewing a single comment's thread. Return to all comments →