nums
array in ascending order.queries
array based on the second element mi
of each query and keep track of the original indices.nums
array (j
) and one for the queries
array (i
).nums
to the Trie that are less than or equal to mi
using the j
pointer.xi
to find the maximum XOR value and store it in the result array at the original index of the query.