wrote brute force code and all test cases are passing, that means it is efficient approach ?
and I’m not understanding approach given in editorial, please explain in detail
Range Xor doubt
No , it is not the efficient approach.
The efficient approach is using trie.
First insert all the bits of all the number in a trie(from msb to lsb) , also for every node in the trie, also store array indexes that passes through it.
Now,to maximise xor,
You start with the msb and see if that bit is set , if that bit is set then we try to find the unset bit that occurs in the given index range (for that , you can use index stored for that node, if any of the values from l to r occurrs then we can take it).Do the same for all the bits ie.if oppsite bit(of value given) is present and is avilable in the given index range then take it.
Else take the bit same as in value.
Do the insertion part,for query of type 0