placeholderBinary Trie

Binary Trie

  1. Introduction
    1. Setting
      Given an array v, find the maximum XOR of two numbers from array v.

    2. Brute-force Solution
      A trivial brute-force approach is O(N2): iterate over each pair of numbers and take the maximum XOR among all pairs.

    3. Idea
      A binary trie stores all the numbers in a trie data structure. For each number, we can find the maximum XOR against all other numbers in v in O(b) time, where b is the number of bits. This reduces the overall complexity to O(Nb).