1915. Number of Wonderful Substrings
Содержание
class Solution:
def wonderfulSubstrings(self, word: str) -> int:
cnt = Counter({0: 1})
res = st = 0
for c in word:
st ^= 1 << (ord(c) - ord("a"))
res += cnt[st]
for i in range(10):
res += cnt[st ^ (1 << i)]
cnt[st] += 1
return res