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