Java Simple Solution
\nimport java.util.*;\nclass Solution {\n    \n    int mod=(int)Math.pow(10,9)+7;\n   // String[] keypad={"","","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz
```\nimport java.util.*;\nclass Solution {\n    \n    int mod=(int)Math.pow(10,9)+7;\n   // String[] keypad={"","","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};\n    int ans=0;\n    public int countTexts(String pressedKeys) {\n        \n        int len=pressedKeys.length();\n       int[] dp=new int[len+1];\n        \n        dp[0]=1;\n        System.out.print(dp[0]+" ");\n        for(int i=1;i<len+1;i++){\n            \n            char ch=pressedKeys.charAt(i-1);\n          \n         \n            \n             dp[i]=(dp[i]%mod+dp[i-1]%mod)%mod;\n            if(i-2>=0 && pressedKeys.charAt(i-2)==ch ){\n                \n                 dp[i]=(dp[i]%mod+dp[i-2]%mod)%mod;\n                \n                if(i-3>=0 &&  pressedKeys.charAt(i-3)==ch ){\n                    \n                    \n                        dp[i]=(dp[i]%mod+dp[i-3]%mod)%mod;\n                    \n                    if((i-4>=0 && pressedKeys.charAt(i-4)==ch)&& (ch==\'7\' || ch==\'9\')  ){\n                        dp[i]=(dp[i]%mod+dp[i-4]%mod)%mod;\n                    }\n                }\n                \n                \n            }\n            \n            \n           // System.out.print(dp[i]+" ");\n        }\n         \n        return dp[len];\n    }\n}\n             \n                   \n```\n
['Dynamic Programming', 'Java']