Java | DP
\nclass Solution {\n    Long[][] mem = null;\n    public int countTexts(String p) {\n        mem = new Long[p.length()+1][10];\n        Stack<int[]> arr = new S
```\nclass Solution {\n    Long[][] mem = null;\n    public int countTexts(String p) {\n        mem = new Long[p.length()+1][10];\n        Stack<int[]> arr = new Stack();\n        for(int i=0; i<p.length(); i++) {\n            if (arr.size() == 0 || arr.peek()[0] != (p.charAt(i)-\'0\')) {\n                arr.push(new int[]{p.charAt(i)-\'0\', 1});\n            } else {\n                arr.peek()[1]++;\n            }\n        }\n        \n        ArrayList<int[]> list = new ArrayList(arr);\n        long prod = 1;\n        for(int[] x: list) {\n            prod *= dp(x[1], x[0])%1000000007;\n            prod = prod % 1000000007;\n        }\n        return (int)(prod%1000000007);\n    }\n    \n    long dp(int c, int l) {\n        int[] let = new int[]{0,0,3,3,3,3,3,4,3,4};\n        if (c <= 0) return 1;\n        if (mem[c][l] != null) return mem[c][l];\n        long ans = 0;\n        for(int i=1; i<=let[l]; i++) {\n            if (c >=i) ans += dp(c-i, l)%1000000007;\n            ans = ans%1000000007;\n        }\n        mem[c][l] = ans;\n        return ans;\n    }\n    \n}\n```
['Dynamic Programming', 'Java']