Minimum XOR value pair
Medium Accuracy: 78.43% Submissions: 2201 Points: 4

Given an array of integers of size N find minimum xor of any 2 elements.

Example 1:

N = 3
arr[] = {9,5,3}
Output: 6
There are 3 pairs -
9^5 = 12
5^3 = 6
9^3 = 10
Therefore output is 6.

Your Task:  
You don't need to read input or print anything. Your task is to complete the function minxorpair() which takes the array arr[], its size N as input parameters and returns the minimum value of xor of any 2 elements.


Expected Time Complexity: O(N)
Expected Auxiliary Space: O(N)


1 <= N <= 105

1 <= arr[i] <= 105

We are replacing the old Disqus forum with the new Discussions section given below.
Click here to view old Disqus comments.

to report an issue on this page.


We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?


All Submissions

My Submissions:

Login to access your submissions.

Minimum XOR value pair

Output Window