Find the minimum value of the given expression over all pairs of the array | Function to find the minimum value of the expression ; The expression simplifies to finding the minimum xor value pair ; Calculate min xor of consecutive pairs ; Driver code
function MinimumValue ( arr , n ) { arr . sort ( ) ; let minXor = Number . MAX_VALUE ; let val = 0 ; for ( let i = 0 ; i < n - 1 ; i ++ ) { val = arr [ i ] ^ arr [ i + 1 ] ; minXor = Math . min ( minXor , val ) ; } return minXor ; } let N = 6 ; let A = [ 12 , 3 , 14 , 5 , 9 , 8 ] ; document . write ( MinimumValue ( A , N ) ) ;