package hackerrank;

import java.util.Scanner;

/**
 * https://www.hackerrank.com/challenges/angry-children
 */
public class MaxMin {
    private static int maxMin(int[] array, int k) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();
        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = in.nextInt();
        }
        System.out.println(maxMin(array, k));
    }
}

@@ -14,16 +14,41 @@
 rrank;%0A%0A
+import java.util.Arrays;%0A
 import j
@@ -65,16 +65,16 @@
 canner;%0A
-
 %0A/**%0A * 
@@ -216,15 +216,267 @@
     
-// TODO
+Arrays.sort(array);%0A        int min = Integer.MAX_VALUE;%0A        for (int i = 0; i %3C array.length; i++) %7B%0A            if (i + k - 1 %3E= array.length) %7B%0A                break;%0A            %7D%0A            min = Math.min(min, array%5Bi + k - 1%5D - array%5Bi%5D);%0A        %7D
 %0A   
@@ -487,17 +487,19 @@
  return 
-0
+min
 ;%0A    %7D%0A

Solve Max Min