CPP | Short and Simple | DP
\nclass Solution {\npublic:\n    int mod=1e9+7;\n    int func(string &s,int i,int n,vector<int> &dp){\n        if(i>=n)return 1;\n        if(dp[i]!=-1)return dp
```\nclass Solution {\npublic:\n    int mod=1e9+7;\n    int func(string &s,int i,int n,vector<int> &dp){\n        if(i>=n)return 1;\n        if(dp[i]!=-1)return dp[i];\n        int ans=0;\n        if(i+1<n && s[i]==s[i+1]){\n            ans+=func(s,i+2,n,dp);\n            ans=ans%mod;\n            if(i+2<n && s[i]==s[i+2]){\n                ans+=func(s,i+3,n,dp);\n                ans=ans%mod;\n                if(i+3<n && s[i]==s[i+3] && (s[i]==\'9\' || s[i]==\'7\'))ans+=func(s,i+4,n,dp);\n                ans=ans%mod;\n            }\n        }\n        ans+=func(s,i+1,n,dp);\n        ans=ans%mod;\n        return dp[i]=ans;\n    }\n    int countTexts(string s) {\n        int n=s.length();\n        vector<int> dp(n+1,-1);\n        return func(s,0,n,dp);\n    }\n};\n```
['Memoization', 'C++']