COINBX - Editorial

Problem Link:

Practice

Setter: saquib ul hassan

Difficulty:
EASY-MEDIUM

Prerequisites:
Array,Bit manipulation

Problem:
He has received a total of N gifts from his N friends. Each of these friends has gifted him with K numbers,calculated the XOR of all the numbers Furthermore, he found the bitwise AND, S of all these XOR values.He has decided to minimize the value of S by toggling at most one bit at any position of a number in any gift that he recieved.
find the minimum value of S.

Quick Explanation:
Since we are only allowed to alter only one bit of the any one of the number . we can choose it from any number and in the patter 2,4,8,16,32,64… and replace its msb bit with 0.

SOLUTION:

Setter