human
Find a number such that maximum in array is minimum possible after XOR | Recursive function that find the minimum value after exclusive - OR.
Condition if ref size is zero or bit is negative then return 0.
Condition if current bit is off then push current value in curr_off vector.
Condition if current bit is on then push current value in curr_on vector.
Condition if curr_off is empty then call recursive function on curr_on vector.
Condition if curr_on is empty then call recursive function on curr_off vector.
Return the minimum of curr_off and curr_on and add power of 2 of current bit.
Function that print the minimum value after exclusive - OR.
Pushing values in vector.
Printing answer.
Driver Code"
Solution in Python:
assistant
#Here is code to find a number such that maximum in array is minimum possible after XOR and the other steps required.
 def RecursiveFunction ( ref , bit ) :
	if ( len ( ref ) == 0 or bit < 0 ) :
		return 0 ;
	curr_on = [ ]
	curr_off = [ ]
	for i in range ( len ( ref ) ) :
		if ( ( ( ref [ i ] >> bit ) & 1 ) == 0 ) :
			curr_off . append ( ref [ i ] )
		else :
			curr_on . append ( ref [ i ] )
	if ( len ( curr_off ) == 0 ) :
		return RecursiveFunction ( curr_on , bit - 1 )
	if ( len ( curr_on ) == 0 ) :
		return RecursiveFunction ( curr_off , bit - 1 )
	return ( min ( RecursiveFunction ( curr_off , bit - 1 ) , RecursiveFunction ( curr_on , bit - 1 ) ) + ( 1 << bit ) )
def PrintMinimum ( a , n ) :
	v = [ ]
	for i in range ( n ) :
		v . append ( a [ i ] )
	print ( RecursiveFunction ( v , 30 ) )
arr = [ 3 , 2 , 1 ]
size = len ( arr )
PrintMinimum ( arr , size )