1759. Count Number of Homogenous Substrings
Содержание
class Solution:
def countHomogenous(self, s: str) -> int:
mod = 10**9 + 7
res = cnt = 1
for a, b in pairwise(s):
cnt = cnt + 1 if a == b else 1
res = (res + cnt) % mod
return res