solution for maximal XOR value problem