Remove exactly one element from the array such that max | function to calculate max - min ; Driver code
function max_min ( a , n ) { a . sort ( ) ; return Math . min ( a [ n - 2 ] - a [ 0 ] , a [ n - 1 ] - a [ 1 ] ) ; } let a = [ 1 , 3 , 3 , 7 ] ; let n = a . length ; document . write ( max_min ( a , n ) ) ;