Count Homogenous Substrings Problem

Count Homogenous Substrings Problem — ExecCode Easy DSA Practice

Solve the Count Homogenous Substrings problem on ExecCode. Free online easy DSA practice in String. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Description You are given a string s, return the number of homogenous substrings of s . Your task is to 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.

Examples

Input {"s": "abbcccaa"}; Output 13. Input {"s": "xy"}; Output 2. Input {"s": "aaaaa"}; Output 15

Constraints

1 <= s.length <= 10^5 s consists of lowercase letters.

Practice Count Homogenous Substrings free on ExecCode. Browse DSA problems, topic map, and placement guides.