Easy to understand solution using combinations and DP.
The approach is like, first of all we will find the number of texts possible for each substring containing same numbers. Then finally multiply all the values po
The approach is like, first of all we will find the number of texts possible for each substring containing same numbers. Then finally multiply all the values possible number of texts for each substring to  get total number of texts possible  for entire string. \nHope you Like it!\n\n\n```\n\nint countTexts(string s) {\n        \n        int n = s.size();\n        int md  = 1e9+7;\n        \n        vector<long long> dp(n,0);\n        dp[0]=1;\n        int cnt = 1;\n        \n        long long ans = 1;\n        \n        for(int i=1;i<n;i++){\n            \n            if(s[i]==s[i-1]){\n                cnt++;\n                if(s[i] == \'7\' || s[i] == \'9\'){\n                    if(cnt<=4){\n                        dp[i] = 1;\n                    }\n                    \n                        int k = min( cnt-1,4);\n                        \n                        while(k){\n                            dp[i]+= dp[i-k];\n                            dp[i] %= md;\n                            k--;\n                        }\n                    \n                }else {\n                    \n                       if(cnt<=3){\n                        dp[i] = 1;}\n                    \n                        int k = min( cnt-1,3);\n                        \n                        while(k){\n                            dp[i]+= dp[i-k];\n                         dp[i] %= md;\n\n                            k--;\n                        }\n                }\n            }else {\n                //reseting the count for new substring with different values.\n                cnt = 1;\n                dp[i] = 1;\n\t\t\t\t\n\t\t\t\t// adding answer to previous substring.\n                ans = (ans*dp[i-1])%md;\n                \n            }\n\t}\n\n\tans = (ans*dp[n-1])%md;\n\n\treturn (int) ans;\n}\n\n```
['Combinatorics']