How to solve this ques?

How to solve this ques?

Hello @haseebshaik00 you have to use TRIE datastructure to implement this question.

Hello @
While solving this question using trie.

  1. At each node of the trie, we will store the ith bit of the number for a query of type 0.
  2. To solve the query of type 1 we will store the indexes of the number that pass through that node.
  3. When we go down the tree during a query and maximizing the xor, we go in a direction that contains at least one index in range L to R, otherwise, we will go in the other direction.
  4. To search if at least one index is within the stored indexes we will use binary search.
    (Since the indices will always be positive, you can apply count sort on them. That will do your work in linear time.)
    Here for your reference i am attaching the code:
    https://ide.codingblocks.com/s/227200?_ga=2.49675874.531836111.1605425451-106244939.1599922571
    if you have any doubt you can ask here:
    Happy Learning !!

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.