text: Minimum increment and decrement by K of each pair elements required to make all array elements equal | Function to check if its possible to make all array elements equal or not ; Stores the sum of the array ; Traverse the array ; If sum is divisible by N ; Otherwise , not possible to make all array elements equal ; Given array ; Size of the array
code: function arrayElementEqual ( arr , N ) { var sum = 0 ; for ( i = 0 ; i < N ; i ++ ) { sum += arr [ i ] ; } if ( sum % N == 0 ) { document . write ( " " ) ; } else { document . write ( " " + " " ) ; } } var arr = [ 1 , 5 , 6 , 4 ] ; var N = arr . length ; arrayElementEqual ( arr , N ) ;