My issue
My code is exceeding time limit and I dont know how to reduce time complexity
My code
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while(t--) {
int n, x;
long long count = 0;
cin >> n;
long long a[n];
unordered_map<long long, long long> m;
for(int i = 0 ; i < n ; ++i) {
cin >> a[i];
for(int j = i-1 ; j >= 0; --j) {
m[a[i] ^ a[j]]++;
}
}
for(auto it : m) {
count += ((it.second)*(it.second-1))/2;
}
cout << 8*count << endl;
}
}
Problem Link: Xometry (Easy Version) Practice Coding Problem