C++ || DP Solution || Clean and Easy to Understand
class Solution {\npublic:\n\n    int mod = 1e9+7;\n \n    int countTexts(string s) {\n\t\n        int n = s.length();\n        vector dp(n+1,0);\n        \n    
class Solution {\npublic:\n\n    int mod = 1e9+7;\n \n    int countTexts(string s) {\n\t\n        int n = s.length();\n        vector<int> dp(n+1,0);\n        \n        dp[0] = 1;\n        int ans = 0;\n        \n        for(int i = 1; i < n+1; i++){\n            \n            dp[i] = (dp[i] + dp[i-1]) % mod;\n            \n            \n            if(i > 1 && s[i-1] == s[i-2])\n                dp[i] =(dp[i] + dp[i-2]) % mod;\n            \n            \n            if(i > 2 && s[i-1] == s[i-2] && s[i-2] == s[i-3])\n                dp[i] =(dp[i] + dp[i-3]) % mod;\n            \n            \n            if(s[i-1] == \'7\' || s[i-1] == \'9\')\n                if(i > 3 && s[i-1] == s[i-2] && s[i-1] == s[i-3] && s[i-1] == s[i-4])\n                    dp[i] =(dp[i] + dp[i-4]) % mod;\n            \n        }\n        \n        return dp[n];\n    }\n};
['Dynamic Programming', 'C', 'C++']