Python bottom up DP+ Explanation
Here is a DP solution :\n\n d contain the number times each key can be pressed to get different characters\n create dp array of length len(pressedKeys)+1. Intia
Here is a DP solution :\n\n* d contain the number times each key can be pressed to get different characters\n* create dp array of length len(pressedKeys)+1. Intialise first element to 1. This is the base case.\n*  c helps us keep track continuous appearence of current digit. This is important because when a number ex:2 is pressed 3 times continuously , it can result in different characters.\n*  DP logic is ```dp[i+1]=(dp[i+1]+dp[i-k])%(10**9+7)```  where k ranges ```range(min(c,d[pressedKeys[i]]))``` keeping in mind that d[pressedKeys[i]] is the max number of times a key/digit can be pressed to get a different character mapping.\n* Finally we return dp[-1]\n\nPlease **Upvote** if you like this solution!\nShare your thoughts in the comments section.\n\n```\nclass Solution:\n    def countTexts(self, pressedKeys: str) -> int:\n        d={\n            "2":3,\n            "3":3,\n            "4":3,\n            "5":3,\n            "6":3,\n            "7":4,\n            "8":3,\n            "9":4\n        }\n        n=len(pressedKeys)\n        dp=[0]*(n+1)\n        dp[0]=1\n\t\t\n        for i in range(n):\n            if pressedKeys[i]==pressedKeys[i-1]:\n                c+=1\n            else:\n                c=1\n            for k in range(min(c,d[pressedKeys[i]])):\n                dp[i+1]=(dp[i+1]+dp[i-k])%(10**9+7)\n        return dp[-1]\n        \n```
['Python']