After So many Tries, Finally Accepted!!
\n\n# Code\n\nclass Solution {\n    HashMap<String,long[]> dp;\n    int mod = (int)Math.pow(10,9)+7;\n    int size;\n    public long helper(int n, String x) {\n
\n\n# Code\n```\nclass Solution {\n    HashMap<String,long[]> dp;\n    int mod = (int)Math.pow(10,9)+7;\n    int size;\n    public long helper(int n, String x) {\n      if(n==0 && x.length()==4) {\n        return 1;\n      } else if(n==0) {\n        return 0;\n      }\n      if(!dp.containsKey(x)) {\n        long arr[] = new long[size+1];\n        Arrays.fill(arr,-1);\n        dp.put(x,arr);\n      }\n      if(dp.get(x)[n]==-1) {\n        int l = 0;\n        int e = 0;\n        int t = 0;\n        for(int i=0; i<x.length(); i++) {\n            if(x.charAt(i)==\'l\') {\n                l++;\n            } else if(x.charAt(i)==\'e\') {\n                e++;\n            } else if(x.charAt(i)==\'t\') {\n                t++;\n            }\n        }\n        long sum = 0;\n        if(l==0) {\n            sum = (sum + helper(n-1,x+\'l\'))%mod;\n        } \n        if(e<2) {\n            sum = (sum + helper(n-1,x+\'e\'))%mod;\n        } \n        if(t==0) {\n           sum = (sum + helper(n-1,x+\'t\'))%mod;\n        }\n        if(x.length()==1 &&(l==1 || t==1)) {\n            sum = (sum + (24*(helper(n-1,x)))%mod)%mod;\n        } else if(x.length()==1 && e==1) {\n            sum = (sum + (23*(helper(n-1,x)))%mod)%mod;\n        }\n        else if(x.length()==2 && e==2) {\n            sum = (sum + (24*(helper(n-1,x)))%mod)%mod;\n        } else if(x.length()==2 && l==1 && t==1) {\n            sum = (sum + (25*(helper(n-1,x)))%mod)%mod;\n        } else if(x.length()==2 && ((l==1 && e==1)||(t==1 && e==1))) {\n            sum = (sum + (24*(helper(n-1,x)))%mod)%mod;\n        } else if(x.length()==3) {\n           sum = (sum + (25*(helper(n-1,x)))%mod)%mod; \n        } else if(x.length()==4) {\n           sum = (sum + (26*(helper(n-1,x)))%mod)%mod;\n        } else if(x.length()==0) {\n            sum = (sum + (23*(helper(n-1,x)))%mod)%mod;\n        }\n        dp.get(x)[n] = sum%mod;\n        }\n      return dp.get(x)[n];\n    }\n    public int stringCount(int n) {\n        size = n+1;\n        dp = new HashMap<>();\n        return (int)helper(n,"");\n    }\n}\n```
['Java']