• + 0 comments

    Java Solution :

    Difference(int[] a){
            this.elements = a;
        }
        
        void computeDifference(){        
            for(int i=0; i<elements.length-1; i++){
                for(int j=i+1; j<elements.length; j++){
                    int diff = Math.abs(elements[i]-elements[j]);
                    if(diff > maximumDifference){
                        this.maximumDifference = diff;             
                    }
                }
            }
        }