You are viewing a single comment's thread. Return to all comments →
I achieved in O(n log n) because of the sort method.
public static void miniMaxSum(List<Integer> arr) { Collections.sort(arr); long minimum = 0; long maximum = 0; for (int i = 0; i < 4; i++) { minimum += arr.get(i); maximum += arr.get(arr.size() - 1 - i); } System.out.printf("%d %d", minimum, maximum); }
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 →
I achieved in O(n log n) because of the sort method.