Python | Recursion+Memoization
\nclass Solution:\n    def countTexts(self, pressedKeys: str) -> int:\n        keysMap={"2":3,"3":3,"4":3,"5":3,"6":3,"7":4,"8":3,"9":4}\n        seen={}\n     
```\nclass Solution:\n    def countTexts(self, pressedKeys: str) -> int:\n        keysMap={"2":3,"3":3,"4":3,"5":3,"6":3,"7":4,"8":3,"9":4}\n        seen={}\n        @lru_cache(10)\n        def find_(ind):\n            if ind>=len(pressedKeys):\n                return 1\n            ans=0\n            for i in range(keysMap[pressedKeys[ind]]):\n                if ind+i >= len(pressedKeys) or pressedKeys[ind+i]!=pressedKeys[ind]:\n                    break\n                ans+=find_(ind+i+1)\n            return ans\n        return find_(0)%1000000007\n            \n```
[]