Maximum XOR of two numbers in an array using Trie

Given a list of numbers we need to identify a pair of numbers in the list such that the XOR of those numbers is the maximum possible over all the pairs. If there are M elements with each element of order N, then brute force approach will take O(M^2 logN) time while Trie solution will take O(M logN) time.

Introduction

Given an array A of N integers, we need to find A[i], A[j] such that A[i] XOR A[j] is the maximum over all i and j, where 1, 1 and i≠j.

Here, by XOR operation, x XOR y, we mean the ...

 •  0 comments  •  flag
Share on Twitter
Published on May 08, 2021 03:45
No comments have been added yet.