package hackerrank;

import java.util.Scanner;

/**
 * https://www.hackerrank.com/challenges/closest-numbers
 */
public class ClosestNumbers {
    private static void closestNumbers(int[] nums) {
        // TODO
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = in.nextInt();
        }
        closestNumbers(nums);
    }
}

@@ -14,16 +14,41 @@
 rrank;%0A%0A
+import java.util.Arrays;%0A
 import j
@@ -65,16 +65,16 @@
 canner;%0A
-
 %0A/**%0A * 
@@ -226,15 +226,491 @@
     
-// TODO
+Arrays.sort(nums);%0A        int%5B%5D diffArray = new int%5Bnums.length%5D;%0A        int min = Integer.MAX_VALUE;%0A        for (int i = 1; i %3C nums.length; i++) %7B%0A            diffArray%5Bi%5D = Math.abs(nums%5Bi - 1%5D - nums%5Bi%5D);%0A            min = Math.min(min, diffArray%5Bi%5D);%0A        %7D%0A        for (int i = 1; i %3C diffArray.length; i++) %7B%0A            if (min == diffArray%5Bi%5D) %7B%0A                System.out.print(nums%5Bi - 1%5D + %22 %22 + nums%5Bi%5D + %22 %22);%0A            %7D%0A        %7D%0A        System.out.println();
 %0A   

Solve Closest Numbers