C++ || Easy Approach || DP || Hahmap
\nclass Solution {\npublic:\n    int mod=1e9+7;\n    map<pair<int,int>,int>mp;\n    void create_map(){\n        mp[{0,1}]=mp[{1,1}]=1;\n        mp[{0,2}]=mp[{1,
```\nclass Solution {\npublic:\n    int mod=1e9+7;\n    map<pair<int,int>,int>mp;\n    void create_map(){\n        mp[{0,1}]=mp[{1,1}]=1;\n        mp[{0,2}]=mp[{1,2}]=2;\n        mp[{0,3}]=mp[{1,3}]=4;\n        mp[{0,4}]=7;\n        mp[{1,4}]=8;\n    }    \n    unsigned int getval(int num,int count){\n        //base case\n        if(mp.count({num,count}))\n            return mp[{num,count}];\n        \n        return mp[{num,count}]=(\n                getval(num,count-1)%mod +\n                getval(num,count-2)%mod +\n                getval(num,count-3)%mod +\n                (num==1 ? getval(num,count-4) : 0)%mod\n            )%mod;\n    }\n    int countTexts(string str) {\n        create_map();\n        str.push_back(\'#\');\n        int n= str.size();\n        long long  ans=1;\n        int count=1;\n        for(int i=0;i<n-1;i++){\n            if(str[i]==str[i+1])\n                count++;\n            else{\n                int num=str[i]-\'0\';\n                long long  curr = getval(num==7 || num==9,count)%mod;\n                count=1;\n                ans=(ans *curr)%mod;\n            }\n        }\n        return ans;\n    }\n};\n```
['Dynamic Programming', 'C++']