Maximum Xor

  • + 0 comments

    the "obvious algorithm" is doing the XOR on each element of the array arr, for each element of the array queries, i.e. there are two nested loops which result in a O(arr.length * queries.length) complexity.

    The trie algorithm is running in O(queries.length * height(trie)) where the height of the trie is the size of an integer (32 bits) so we can consider the height constant, which makes the whole algorithm run linearly, overall.