c++ simple solution
\nclass Solution {\npublic:\n    int countTexts(string pressedKeys) {\n        std::vector<long> dp(pressedKeys.size(), 0);\n        dp[0] = 1;\n        for (in
```\nclass Solution {\npublic:\n    int countTexts(string pressedKeys) {\n        std::vector<long> dp(pressedKeys.size(), 0);\n        dp[0] = 1;\n        for (int i = 1; i < pressedKeys.size(); ++i) {\n            char ch = pressedKeys[i];\n            int max_num = (ch == \'7\' || ch == \'9\') ? 4 : 3;\n\n            for (int j = 0; j < max_num; ++j) {\n                if (i - j < 0 || pressedKeys[i - j] != ch) break;\n                dp[i] += (i - j - 1 < 0) ? 1 : dp[i - j - 1];\n            }\n\n            dp[i] %= modulo_;\n        }\n        \n        return dp.back();\n    }\nprivate:\n    int modulo_ = 1000000007;\n};\n```
[]