C++ || DP || o(n) solution
\nlong long mod=1000000007;\n    \n    long long ans[100001];\n    \n    long long solve(string &s,int i)\n    {\n        if(i==s.size())\n        {\n          
```\nlong long mod=1000000007;\n    \n    long long ans[100001];\n    \n    long long solve(string &s,int i)\n    {\n        if(i==s.size())\n        {\n            return 1;\n        }\n        \n        if(ans[i]!=-1)\n        {\n            return ans[i];\n        }\n        \n        long long cnt=0;\n        \n        if(s[i]==\'9\'||s[i]==\'7\')\n        {\n            char c=s[i];\n            \n            for(int j=i;j<i+4;j++)\n            {\n                if(s[j]==c)\n                {\n                    cnt=(cnt+solve(s,j+1))%mod;\n                }\n                else\n                {\n                    break;\n                }\n            }\n        }\n        else\n        {\n            char c=s[i];\n            \n            for(int j=i;j<i+3;j++)\n            {\n                if(s[j]==c)\n                {\n                    cnt=(cnt+solve(s,j+1))%mod;\n                }\n                else\n                {\n                    break;\n                }\n            }\n        }\n        ans[i]=cnt%mod;\n        return ans[i];\n    }\n    int countTexts(string pressedKeys) \n    {\n        memset(ans,-1,sizeof(ans));\n        \n        long long fans=solve(pressedKeys,0);\n        return fans;\n    }\n\t```
[]