@@ -0,0 +1,2434 @@
+package thirty_days_of_code;%0D%0A%0D%0Aimport java.util.Scanner;%0D%0A%0D%0A/*%0D%0A * Problem Statement:%0D%0A * In this challenge, you will create a program that takes N non-negative%0D%0A * integers as input and finds the greatest absolute difference between two of%0D%0A * the N integers, and then print this difference to the console.%0D%0A * %0D%0A * There is a class Difference given in the editor with one private instance%0D%0A * array elements which stores the N non negative integers and public integer%0D%0A * maxDifference to store the greatest absolute difference between the two of%0D%0A * the N integers.%0D%0A * %0D%0A * Code for handling input/output is already given in the editor. Your task is%0D%0A * to write the constructor for the class Difference and the method%0D%0A * computeDifference which finds the greatest absolute difference between any%0D%0A * two numbers in the input array and stores it in maxDifference.%0D%0A * %0D%0A * Input Format: %0D%0A * First line contains an integer N representing size of the array. Next line%0D%0A * contains N integers separated by space.%0D%0A * %0D%0A * Constraints:%0D%0A * 1 %3C= N %3C= 10%0D%0A * 1 %3C= elements%5Bi%5D %3C= 100 where 1 %3C= i %3C= N%0D%0A * %0D%0A * Output Format: %0D%0A * Output the the greatest absolute difference between two of N integers in the%0D%0A * array.%0D%0A * %0D%0A * Sample Input: %0D%0A * 3%0D%0A * 1 2 5%0D%0A * %0D%0A * Sample Output: %0D%0A * 4%0D%0A */%0D%0Apublic class AllAboutScope %7B%0D%0A%0D%0A  %09public static void main(String%5B%5D args) %7B%0D%0A    %09Scanner sc = new Scanner(System.in);%0D%0A    %09int N = sc.nextInt();%0D%0A    %09int%5B%5D a = new int%5BN%5D;%0D%0A    %0D%0A    %09for (int i = 0; i %3C N; i++) %7B%0D%0A    %09%09a%5Bi%5D = sc.nextInt();%0D%0A    %09%7D%0D%0A%0D%0A      %09Difference D = new Difference(a);%0D%0A%0D%0A        D.computeDifference();%0D%0A%0D%0A        System.out.print(D.maximumDifference);%0D%0A        sc.close();%0D%0A   %7D%0D%0A%7D%0D%0A%0D%0Aclass Difference %7B%0D%0A  %09private int%5B%5D elements;%0D%0A  %09public int maximumDifference;%0D%0A  %09%0D%0A    Difference (int%5B%5D array) %7B%0D%0A        elements = array;%0D%0A        maximumDifference = computeDifference();%0D%0A    %7D%0D%0A%0D%0A    public int computeDifference() %7B%0D%0A        int maxDiff = 0;%0D%0A        if (elements.length %3E 1) %7B%0D%0A            for (int i = 0; i %3C elements.length - 1; i++) %7B%0D%0A                int currDiff;%0D%0A                for (int j = i + 1; j %3C elements.length; j++) %7B%0D%0A                    currDiff = Math.abs(elements%5Bi%5D - elements%5Bj%5D);%0D%0A                    if (currDiff %3E maxDiff) %7B%0D%0A                        maxDiff = currDiff;%0D%0A                    %7D%0D%0A                %7D%0D%0A            %7D%0D%0A        %7D%0D%0A        return maxDiff;%0D%0A    %7D%0D%0A%7D

Add AllAboutScope