• + 0 comments

    C#

        public Difference(int[] elements)
        {
            this.elements = elements;
            this.maximumDifference = 0;
        }
    
        public int computeDifference()
        {
            Array.Sort(elements);
            
            //getting max and min values and getting the abs difference of them
            maximumDifference = Math.Abs(elements[0] - elements[elements.Length-1]);
            
            return maximumDifference;
        }