Min XOR value - InterviewBit Solution

Problem: Min XOR value

Problem Description:

Given an integer array A of N integers, find the pair of integers in the array which have minimum XOR value. Report the minimum XOR value.

Input Format:

The first and only argument of input contains an integer array A

Output Format:

return a single integer denoting minimum xor value


2 <= N <= 100 000   
0 <= A[i] <= 1 000 000 000 

For examples,

Example Input 1:
    A = [0, 2, 5, 7]
Example Output 1:
    0 xor 2 = 2
Example Input 2:
    A = [0, 4, 7, 9]
Example Output 2:

Solution Approach:

Solution in C++:

If you have any questions or queries, feel free to drop a comment in the comments section below.

Note: Help us improve this blog

If you have a better solution, and you think you can help your peers to understand this problem better, then please drop your solution and approach in the comments section below.

We will upload your approach and solution here by giving you the proper credit so that you can showcase it among your peers.