Dsa
Bit Manipulation
Easy
Maximum XOR Pair
You are given an array of integers. Write a program that finds the maximum XOR of any two distinct elements in the array.
Input format:
- The first line contains an integer T (1 <= T <= 100), the number of test cases.
- The next T lines each contain an integer M (1 <= M <= 1000) followed by M space-separated integers.
Output format:
- For each test case, output a single integer representing the maximum XOR value.
Example:
Input:
1
5 1 2 3 4 5
Output:
7
(The maximum XOR can be obtained from 3 XOR 4.)
Key concepts
bit_manipulationxor
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now