C++ recursive O(N) solution
\nclass Solution {\n    \n    #define ll long long \n    int mod = 1000000007 ;\n    \n    int go( string &A , int i , ll t[] )\n    {\n        int N = A.size()
```\nclass Solution {\n    \n    #define ll long long \n    int mod = 1000000007 ;\n    \n    int go( string &A , int i , ll t[] )\n    {\n        int N = A.size();\n        if(t[i] != -1 ) return t[i] ;\n        \n        ll res = go( A , i+1 , t )%mod ;  // default case \n        \n        if( i+1 < N && A[i+1] == A[i] )\n            res += go( A , i+2 , t );  // two consecutive can be grouped \n        \n        res %= mod ;\n        \n        if( i+2 < N && A[i+1] == A[i] && A[i+2] == A[i] )\n            res += go( A , i+3 , t ); // three consecutive can be grouped \n        \n        res %= mod ;\n        \n        if( A[i] == \'7\' || A[i] == \'9\' ) // special cases \n        {\n            if( i+3 < N && A[i+1] == A[i] && A[i+2] == A[i] && A[i+3] == A[i] )\n                res += go( A , i+4 , t ); // 4 consecutive can be grouped \n        }\n        \n        return t[i] = res%mod ;\n    }\n    \npublic:\n    int countTexts(string A ) {\n        \n        int N = A.size();\n        ll t[N+1];\n        memset( t , -1 , sizeof t );\n        t[N] = 1 ;\n        \n        return go( A , 0 , t )%mod ;\n    }\n};\n```
['C']