C++ | Simple DP
\nclass Solution {\npublic:\n    int mod=1e9+7;\n    int countTexts(string &s) \n    {\n        int n=s.size();\n        int dp[n];\n        dp[0]=1;\n        f
```\nclass Solution {\npublic:\n    int mod=1e9+7;\n    int countTexts(string &s) \n    {\n        int n=s.size();\n        int dp[n];\n        dp[0]=1;\n        for(int i=1;i<n;i++)\n        {\n            dp[i]=dp[i-1];\n            if(s[i]==s[i-1])\n                dp[i]=i>1?(dp[i]+dp[i-2]):(dp[i]+1);\n            dp[i]%=mod;\n            if(i>1 && s[i]==s[i-1] && s[i]==s[i-2])\n                dp[i]=i>2?(dp[i]+dp[i-3]):(dp[i]+1);\n            dp[i]%=mod;\n            if(i>2 && (s[i]==\'7\' || s[i]==\'9\') && s[i]==s[i-1] && s[i]==s[i-2] && s[i]==s[i-3])\n                dp[i]=i>3?(dp[i]+dp[i-4]):(dp[i]+1);\n            dp[i]%=mod;\n        }\n        return dp[n-1];\n    }\n};\n```
[]