Given an array of integers A and a query integer Q. Find the number X in the array such that it can be converted from Q to X such that F(Q,X) is minimum.
F(A,B)=Number of bits flipped to change the number A to B.
If there are more than one values in A such that F(Q,X) is minimum print the smallest value of X for which F(Q,X) is minimum.
The first line of the test case contains an Integer T denoting number of test case. The first line of each test case contains two integer N and Q denoting the size of the array and the query, the second line contains N space separated integer A[i], where A[i] denotes the ith element of the array.
5 32 1 7 10 50 19 21 2
5 32 10 7 10 50 19 21 2
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.