Count Number of texts
Code
# Code
```java []
class Solution {
    int mod = 1000000007;

    public int countTexts(String s) {
        int[] key = new int[]{0, 0, 3,3,3,3,3,4,3,4};
        int n = s.length();
        int[] dp = new int[n];
        Arrays.fill(dp, -1);
        return solve(s, key, 0, dp);
    }

    public int solve(String s, int[] key, int idx, int[] dp){
        if(idx==s.length()){
            return 1;
        }
        if(dp[idx]!=-1){
            return dp[idx];
        }

        int count = 0;
        int num = s.charAt(idx)-'0';
        int rep = key[num];
        for(int i=0;i<rep && idx+i<s.length() && s.charAt(idx)==s.charAt(idx+i);i++){
            count += solve(s, key, idx+1+i, dp);
            count %= mod;
        }
        return dp[idx]=count;
    }
}
```
['Math', 'String', 'Dynamic Programming', 'Java']