C++ Solution | DP | Bottom Up Approach
\nclass Solution {\npublic:\n    int countTexts(string s) {\n        int n = s.size();\n        int mod = 1e9 + 7;\n        vector<int> dp(n + 1);\n        dp[0
```\nclass Solution {\npublic:\n    int countTexts(string s) {\n        int n = s.size();\n        int mod = 1e9 + 7;\n        vector<int> dp(n + 1);\n        dp[0] = 1;\n        for (int i = 0; i < n; i++)\n        {\n            dp[i + 1] = dp[i];\n            if (i > 0 and s[i] == s[i - 1])\n            {\n                dp[i + 1] = (dp[i + 1] + dp[i - 1]) % mod;\n                if (i > 1 and s[i] == s[i - 2])\n                {\n                    dp[i + 1] = (dp[i + 1] + dp[i - 2]) % mod;\n                    if (i > 2 and s[i] == s[i - 3] and (s[i] == \'7\' or s[i] == \'9\'))\n                        dp[i + 1] = (dp[i + 1] + dp[i - 3]) % mod;\n                }\n            }\n        }\n        return dp[n];\n    }\n};\n```
[]