No k is not always 2^(maxbit) - 1. We are calculating it in two steps. First maintaing a prefix vector which have XOR of elemnt till the current index. And the to find K value we have to XOR it with the number ranging from 0 to 2^(maxbit) which is 2^maxBit . And how to come up with knowing how only 2^maxBit giving the right K answer at the end we have to dry run the code manually.
K is the maximum of XOR of all numbers after removing last element in each step and then do XOR with the maxBit ranging from 0 to 2^maxBit...as stated in question. Try doing dry run of the code you will understand it better.
why k is alwsay 2^(maxBit)-1 because if k is 4 and the xor of array is 6 then 6 xor 9 gives maxAnswer than 6xor15 right
No k is not always 2^(maxbit) - 1. We are calculating it in two steps. First maintaing a prefix vector which have XOR of elemnt till the current index. And the to find K value we have to XOR it with the number ranging from 0 to 2^(maxbit) which is 2^maxBit . And how to come up with knowing how only 2^maxBit giving the right K answer at the end we have to dry run the code manually.
Mam, can you explain that "K'' i mean in example cases how that K is calculated ? 😭
K is the maximum of XOR of all numbers after removing last element in each step and then do XOR with the maxBit ranging from 0 to 2^maxBit...as stated in question. Try doing dry run of the code you will understand it better.