Minimum AND xor OR
Practice
3.6 (83 votes)
1 D array
Arrays
Data structures
Operators
Sorting
Problem
92% Success 26573 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code
You are given an array \(A\) of \(N\) integers. Determine the minimum value of the following expression for all valid \(i,j\):
\((A_i \ and \ A_j) \ xor \ (A_i \ or \ A_j)\), where \(i \ne j\).
Input format
- First line: A single integer \(T\) denoting the number of test cases
- For each test case:
- First line contains a single integer \(N\), denoting the size of the array
- Second line contains \(N\) space-separated integers \(A_1,A_2,...,A_n\)
Output format
For each test case, print a single line containing one integer that represents the minimum value of the given expression
Constraints
\(1 \le T \le 10^3\\ 1 \le N \le 10^5\\ 0 \le A_i \le 10^9\)
Note: Sum of \(N\) overall test cases does not exceed \(10^6\)
Submissions
Please login to view your submissions
Similar Problems
Points:30
32 votes
Tags:
Data StructuresEasyOne-dimensional
Points:30
44 votes
Tags:
ArraysData StructuresPrefix1-DHashing
Points:30
15 votes
Tags:
Data StructuresEasyMathOne-dimensionalSets
Editorial