Hackerrank Day 14 scope 30 days of code solution YASH PAL, 31 July 202412 October 2025 In this HackerRank Day 14 scope 30 days of code problem, we have given A class constructor that takes an array of integers as a parameter and saves it to the instance variable. A computeDifference method finds the maximum absolute difference between any numbers and stores it in the instance variable.ObjectiveToday we’re discussing scope. The absolute difference between two integers, a and b, is written as |a -b|. The maximum absolute difference between two integers in a set of positive integers, elements, is the largest absolute difference between any two integers in _elements. The Difference class is started for you in the editor. It has a private integer array (elements) for storing N non-negative integers, and a public integer (maximumDifference) for storing the maximum absolute difference.TaskComplete the Difference class by writing the following:A class constructor that takes an array of integers as a parameter and saves it to the _elements instance variable.A computeDifference method that finds the maximum absolute difference between any 2 numbers in _elements and stores it in the maximumDifference instance variable. Input FormatYou are not responsible for reading any input from stdin. The locked Solution class in the editor reads in 2 lines of input. The first line contains N, the size of the elements array. The second line has N space-separated integers that describe the _elements array.Constraints1 <= N <= 101 <= _elements[i] <= 100,where 0 <= i <= N-1Output FormatYou are not responsible for printing any output; the Solution class will print the value of the maximumDifference instance variable.Problem solution in Python 2. # Add your code here def computeDifference(self): maxDiff = 0 arr = self.__elements for i in range(len(arr)): for j in range(i+1, len(arr)): if abs(arr[j] - arr[i]) > maxDiff: maxDiff = abs(arr[j] - arr[i]) self.maximumDifference = maxDiffProblem solution in Python 3. self.maximumDifference = 0 def computeDifference(self): x = 101 y = 0 for item in self.__elements: if item < x: x = item if item > y: y = item self.maximumDifference = y - x # Add your code here Problem solution in java. // Add your code here public Difference(int[] nums) { elements = nums; } public void computeDifference() { Arrays.sort(elements); maximumDifference = elements[elements.length - 1] - elements[0]; }Problem solution in C++. // Add your code here Difference(vector<int> arr){ elements = arr; sort(elements.begin(), elements.end()); } void computeDifference(){ maximumDifference = abs(elements[elements.size()-1] - elements[0]); } 30 days of code coding problems solutions HackerRank