Count Number of Homogenous Substrings
Given a string s, return the number of homogenous substrings of s. Since the answer may be too large, return it modulo 10^9 + 7.
A string is homogenous if all the characters of the string are the same.
A substring is a contiguous sequence of characters within a string.
Example 1
Input
s = "abbcccaa"Output
13The homogenous substrings are counted as 3 occurrences of "a", 1 of "aa", 2 of "b", 1 of "bb", 3 of "c", 2 of "cc", and 1 of "ccc", totaling 13.
Example 2
Input
s = "xy"Output
2The homogenous substrings are "x" and "y".
Constraints
- 1 <= s.length <= 10^5
- s consists of lowercase letters.