You are viewing a single comment's thread. Return to all comments →
Java
public static int maxMin(int k, List<Integer> arr) { Collections.sort(arr); int unfairness; int minUnfairness = arr.get(k-1) - arr.get(0); for (int i = 1; i <= arr.size()-k; i++) { unfairness = arr.get(i+k-1) - arr.get(i); if (unfairness < minUnfairness){ minUnfairness = unfairness; } } return minUnfairness; }
Seems like cookies are disabled on this browser, please enable them to open this website
Max Min
You are viewing a single comment's thread. Return to all comments →
Java