-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
Bit_Trie Implementation for Max Xor Computation in an Array #3022
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Bit_Trie Implementation for Max Xor Computation in an Array #3022
Conversation
* each number in the array. | ||
* | ||
* Worst Case Time Complexity: O(n * log(MAX_VAL)) where MAX_VAL is the maximum | ||
* value in the array (64-bit integers here) Space Complexity: O(n * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line break for the space complexity
* @param nums vector of unsigned 64-bit integers | ||
* @return maximum XOR of any pair | ||
*/ | ||
std::uint64_t findMaximumXOR(const std::vector<std::uint64_t>& nums) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Follow snake case.
*/ | ||
static void test() { | ||
using bit_manipulation::max_xor_bit_trie::findMaximumXOR; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add empty vector test.
Hello i have commited the changes that you requested for also followed snake case conventions,could you please review the changes |
Description of Change
This pull request adds a C++ implementation of the Bitwise Trie (Binary Trie) to solve the Maximum XOR of Two Numbers in an Array problem from LeetCode: Maximum XOR Problem.
The algorithm constructs a binary trie for all 64-bit integers in the array and efficiently queries the maximum XOR achievable for each number. The implementation is self-contained, includes comprehensive Doxygen-style documentation, and comes with multiple test cases to ensure correctness.
Checklist
max_xor_bit_trie.cpp
)Notes: Implements an efficient O(n * log(MAX_VAL)) solution for finding the maximum XOR pair in an array using a bitwise trie. Includes extensive tests for edge cases, duplicates, and large arrays.