Code : Minimum XOR Pair
#include <bits/stdc++.h>
using namespace std;
void solve(vector<int> &a) {
int n = a.size();
sort(a.begin(), a.end());
int res = (1 << 30) - 1;
for (int i = 1; i < n; i++) {
res = min(res, a[i] ^ a[i - 1]);
}
cout << res << endl;
}
int main() {
int t;
cin >> t;
for (int zz = 0; zz < t; zz++) {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
solve(a);
}
return 0;
}