1
class Solution {
2
public:
3
int countTriplets(vector<int> &a) {
4
int n = a.size();
5
unordered_map<int, int> mp;
6
for (int i = 0; i < n; i++) {
7
for (int j = 0; j < n; j++) {
8
mp[(a[i] & a[j])]++;
9
}
10
}
11
int ans = 0;
12
for (auto &op : mp) {
13
for (int i = 0; i < n; i++) {
14
if (op.first & a[i]) {
15
} else {
16
ans += op.second;
17
}
18
}
19
}
20
return ans;
21
}
22
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0