Skip to content

Conversation

DataWorshipper
Copy link

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

  • Added description of change
  • Added file name matches File name guidelines (max_xor_bit_trie.cpp)
  • Added tests and example, test must pass
  • Added documentation so that the program is self-explanatory and educational - Doxygen guidelines
  • Relevant documentation/comments is changed or added
  • PR title follows semantic commit guidelines
  • Search previous suggestions before making a new one, as yours may be a duplicate.
  • I acknowledge that all my contributions will be made under the project's license.

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.

* 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 *
Copy link
Collaborator

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) {
Copy link
Collaborator

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;

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add empty vector test.

@DataWorshipper
Copy link
Author

Hello i have commited the changes that you requested for also followed snake case conventions,could you please review the changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants