Maximum XOR of Two Numbers in an Array | Function to return the maximum xor ; Calculating xor of each pair ; Driver Code
function max_xor ( arr , n ) { let maxXor = 0 ; for ( let i = 0 ; i < n ; i ++ ) { for ( let j = i + 1 ; j < n ; j ++ ) { maxXor = Math . max ( maxXor , arr [ i ] ^ arr [ j ] ) ; } } return maxXor ; } let arr = [ 25 , 10 , 2 , 8 , 5 , 3 ] ; let n = arr . length ; document . write ( max_xor ( arr , n ) ) ;