Created
June 27, 2021 22:13
-
-
Save JonathanLalou/3b20c33e0c2ed143d09dddefe59c0004 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static int maxMin(int k, List<Integer> arr) { | |
// Write your code here | |
if (k == 1) return 0; | |
Collections.sort(arr); | |
int unfairness = Integer.MAX_VALUE; | |
int size = arr.size(); | |
for (int i = 0; i <= size - k; i++) { | |
unfairness = Math.min(unfairness, arr.get(i + k - 1) - arr.get(i)); | |
} | |
return unfairness; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
15' (5' for the first version, 10' to fix the test#16 !!!!!)