classSolution { public: intcountHomogenous(string s){ longlong MOD = 1e9 + 7; int left = 0; longlong ans = 0; for (int i = 1; i < s.length(); i++) { if (s[i] != s[left]) { ans += (i - left) * (i - left + 1) / 2; ans %= MOD; left = i; } } ans += (s.length() - left) * (s.length() + 1 - left) / 2; return ans % MOD; } };