1915.cpp (466B)
1 class Solution { 2 3 public: 4 long long wonderfulSubstrings(const string &word) const { 5 6 long long count[1 << 11] = {1}, res = 0; 7 8 uint16_t crnt = 0; 9 10 for (int i = 0; i < size(word); i++) { 11 12 crnt ^= 1 << (word[i] - 'a'); 13 14 res += count[crnt]; 15 16 for (int j = 0; j < 10; j++) { 17 18 res += count[crnt ^ (1 << j)]; 19 } 20 21 count[crnt]++; 22 } 23 24 return res; 25 } 26 };