Skip to content

Latest commit

 

History

History
20 lines (17 loc) · 493 Bytes

9.md

File metadata and controls

20 lines (17 loc) · 493 Bytes
 long long mod=1e9 +7;
    int countHomogenous(string s) {
        int length=0;
        long long ans=0;

        for(int i=0;i<s.size();i++)
        {
            if(i!=0 && s[i]==s[i-1])
                length++;
            else
                length=1;
            ans = (ans + length) % mod;
        }

        return ans%mod;
    }