CodeForces Round #647 div2

my solution which gives me the correct ans:
in this above solution i use simple for loop to get the value of k.
But if i replace it with binary-search i am getting wrong output:
Please can anyone tell what mistake am i making

Yeah, if check is false why are you changing l=mid+1?

Your binary search would work only if for a certain value of K and above the statement held always true. (The statement was minimum K for which xor of K and every element s would return the same elements at the end)

As far as I am aware the above claim is not true.


Let say if your check is giving 0. Then l=mid+1 according to your code. But how can you say that k will be in other half ? Also, your code is giving wrong output for sample TC