Maximum XOR of Two Numbers in an Array | Function to return the maximum xor ; Calculating xor of each pair ; Driver Code
def max_xor ( arr , n ) : NEW_LINE INDENT maxXor = 0 ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT for j in range ( i + 1 , n ) : NEW_LINE INDENT maxXor = max ( maxXor , \ arr [ i ] ^ arr [ j ] ) ; NEW_LINE DEDENT DEDENT return maxXor ; NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ 25 , 10 , 2 , 8 , 5 , 3 ] ; NEW_LINE n = len ( arr ) ; NEW_LINE print ( max_xor ( arr , n ) ) ; NEW_LINE DEDENT