human
Bitwise AND of sub | Function to return the minimum possible value of | K - X | where X is the bitwise AND of the elements of some sub - array.
Check all possible sub - arrays.
Find the overall minimum.
Driver code"
Solution in Python:
assistant
#Here is code to bitwise AND of sub and the other steps required.
 def closetAND ( arr , n , k ) :
	ans = 10 ** 9
	for i in range ( n ) :
		X = arr [ i ]
		for j in range ( i , n ) :
			X &= arr [ j ]
			ans = min ( ans , abs ( k - X ) )
	return ans
arr = [ 4 , 7 , 10 ]
n = len ( arr )
k = 2 ;
print ( closetAND ( arr , n , k ) )