classSolution { public: intsingleNumber(vector<int>& nums){ int ret = 0; for (int i = 0; i < 32; i ++) { int cnt = 0; for (auto num: nums) { cnt += num >> i & 1; } if (cnt % 3 != 0) { ret |= 1 << i; } } return ret; } };
classSolution { public: intmaxProduct(vector<string>& words){ int n = words.size(); vector<int> dict(n, 0); for (int i = 0; i < words.size(); i ++) { int t = 0; for (auto c: words[i]) { int bit = c - 'a'; t |= (1 << bit); } dict[i] = t; }
int ans = 0; for (int i = 0; i < n; i ++) for (int j = 0; j < i; j ++) if ((dict[i] & dict[j]) == 0) { int temp = words[i].size() * words[j].size(); ans = max(ans, temp); } return ans; } };