My DP Memoization easy to understand
Intuition\n Describe your first thoughts on how to solve this problem. \n\n    just have special cycles for index+1,index+2 and index+3 elements.\nIf they are e
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n    just have special cycles for index+1,index+2 and index+3 elements.\nIf they are equal like 222 or 7777 then we can take this in cosideration.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int mod = 1e9 + 7;\n    int size = 1e5+10;\n    int dp[100000];\n    int solve(int ind, string &str, vector<string>& nummap){\n        \n        if(str[ind] == \'0\' || str[ind]==\'1\') return 0;\n        if(ind == str.size()) return 1;\n\n        if(dp[ind] != -1) return dp[ind];\n\n        long long int ans = 0;\n\n        if(ind<str.size()-1 && str[ind+1]==str[ind]){\n            ans += solve(ind+2,str,nummap)%mod;\n        }\n\n        if(ind<str.size()-2 && (str[ind]==str[ind+1] && str[ind+1]==str[ind+2])){\n            ans += solve(ind+3,str,nummap)%mod;\n        }\n\n        if(ind<str.size()-3 && (str[ind]==\'7\' || str[ind]==\'9\') &&( str[ind+1]==str[ind] && str[ind+2]==str[ind]  && str[ind+3]==str[ind])){\n            ans += solve(ind+4,str,nummap)%mod;\n        }\n\n        ans += solve(ind+1,str,nummap)%mod;\n\n        return dp[ind] = ans%mod;\n\n    }\n\n    int countTexts(string pressedKeys) {\n        \n        vector<string> nummap {"","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};\n        memset(dp,-1,sizeof(dp));\n        return solve(0,pressedKeys,nummap)%mod;\n    }\n};\n```
['C++']