Geeksforgeeks

X

DAYS

:

HOUR

:

MINS

:

SEC

Error

Copied to Clipboard

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

**Example 1:**

Input: N = 3 arr[] = {9,5,3}Output:6Explanation: 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)

**Constraints:**

1 <= N <= 10^{5}

1^{ }<= arr[i] <= 10^{5}

We are replacing the old Disqus forum with the new Discussions section given below.

Click here to view old Disqus comments.

Click here to view old Disqus comments.

Login 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?

YesLoading...

Minimum XOR value pair

...