We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
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.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Maximum Xor
You are viewing a single comment's thread. Return to all 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.