You are viewing a single comment's thread. Return to all comments →
Java with streams:
public static void miniMaxSum(List<Integer> arr) { arr.sort(Comparator.naturalOrder()); long min = arr.stream() .mapToLong(ele -> (long) ele) .limit(arr.size() - 1) .reduce(0L, Long::sum); long max = arr.stream() .mapToLong(ele -> (long) ele) .skip(1L) .reduce(0L, Long::sum); System.out.println(min + " " + max); }
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 →
Java with streams: