Test case 2 failing

hello @varun.saxena
u should call max xor function for each each position i.

refer this -> https://ide.codingblocks.com/s/255247

hi, I checked out your code. I have the following questions:

  1. Why are you checking for a max xor when the trie isn’t built completely for all elements? Say, if you know that you range of answer is from 3->5 but you kept searching for a max xor between 0-4 even when you won’t find the answer there right?
  2. In my logic, I kept a track for the max number which would have the largest MSB right, from the pre-array of xors? After I have a maximum, I just need to find the matching element from the pre-array to make the xor maximum, like searching for the max-pair in effect. So, I have to access the trie for a read only once.
  1. subarray will start from some index and end at some right?
    now what logic i m applying is, i m considering each index i as the ending index of the subarray and then with the help of max function i m trying to find for max xor simple?.
    so this will consider every case and at the end give overall subarray.

  2. this assumption is not correct,u r assuming that u will get max xor only with max prefix which is not true.
    two prefix xors that are not maximum can also make max xor subarray

Oh right. Got it, I was concentrating a lot on keeping the MSB maximum and 1. But, yes, two values can have the same MSB and the smaller could give a better xor if the appropriate match exists.
Thanks.