leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

1915.cpp (466B)


0 class Solution {
2 public:
3 long long wonderfulSubstrings(const string &word) const {
5 long long count[1 << 11] = {1}, res = 0;
7 uint16_t crnt = 0;
9 for (int i = 0; i < size(word); i++) {
11 crnt ^= 1 << (word[i] - 'a');
13 res += count[crnt];
15 for (int j = 0; j < 10; j++) {
17 res += count[crnt ^ (1 << j)];
18 }
20 count[crnt]++;
21 }
23 return res;
24 }
25 };