Hi, Naman,
I have a O(32n) algorithm. You can solve this problem by creating a
empty Trie <http://en.wikipedia.org/wiki/Trie>, then you add each number's
binary form(from high to low) into the Trie.
For each number X, start from the root of the Trie, if mth bit of X is
P(0 or 1), then consider the the current place you reach now in the Trie, if
the ~P son node is NON-empty, then you go along with ~P, otherwise you go
along with P. Then you can get the the number which has the maximum result
when XOR with X.
Then just compare the n XOR result you get, what you want is the pair
with largest result.
On Wed, Aug 31, 2011 at 12:50 AM, Naman Mahor <[email protected]> wrote:
> Given n unsigned integer, output 2 integers which has the maximum result
> after XOR.
> <http://geeksforgeeks.org/forum/topic/strings>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
--
from Yuchen Liao via Gmail
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.