DP with memoization. Easily explained
Intuition\nI feel like this question is a good dynamic programming question.\nAt the end we need to have one \'l\' and two \'e\' and one \'t\' for sure.\nso we 
# Intuition\nI feel like this question is a good dynamic programming question.\nAt the end we need to have one \'l\' and two \'e\' and one \'t\' for sure.\nso we can think like we have three targets and we need to find number of ways to finish these three targets using lower case alphabets.\nThink it like a classical dp problem where we will be given some coins and we need to find number of ways to form the given target. Same kind of approach can be used in this question but here we have three targets to achieve and our coins here are lower case alphabets\n\n# Approach\nAssume if question is to find number of ways to form a target with given coins. In this question we maintain two states which are index and target/sum remaining. We use same kind of logic here. We maintain 4 DP states in which one is index and rest 3 are target alphabets. Now transitions are simple\nwe iterate over all characters here \n1) If character is \'l\' we reduce the target count of \'l\' and move to next index\n2) If character is \'e\' we reduce the target count of \'e\' and move to next index\n3) If character is \'t\' we reduce the target count of \'t\' and move to next index\n4) Else we just move to next index\n\nNow base case is simple. If u reached the end then your all targets must be zero. Then only a combination is possible else it won\'t.\nSo we will check that in base case.\n\n# Code\n```\nclass Solution {\npublic:\n    int mod=1e9+7;\n    int dp[100002][2][3][2];\n    long long f(int i,int n,int l,int e,int t){\n        if(i>n){\n            if(l==0 and e==0 and t==0){\n                return 1;\n            }\n            else{\n                return 0;\n            }\n        }\n        if(dp[i][l][e][t]!=-1){\n            return dp[i][l][e][t]%mod;\n        }\n        long long cnt=0;\n        for(char ch=\'a\';ch<=\'z\';ch++){\n            if(ch==\'l\'){\n                cnt=(cnt%mod+f(i+1,n,max(0,l-1),e,t)%mod)%mod;\n            }\n            else if(ch==\'e\'){\n                cnt=(cnt%mod+f(i+1,n,l,max(0,e-1),t)%mod)%mod;\n            }\n            else if(ch==\'t\'){\n                cnt=(cnt%mod+f(i+1,n,l,e,max(0,t-1))%mod)%mod;\n            }\n            else{\n                cnt=(cnt%mod+f(i+1,n,l,e,t)%mod)%mod;\n            }\n        }\n        return dp[i][l][e][t]=cnt%mod;\n    }\n    int stringCount(int n) {\n        memset(dp,-1,sizeof(dp));\n        long long ans=f(1,n,1,2,1)%mod;\n        return ans%mod;\n    }\n};\n```
['Dynamic Programming', 'Memoization', 'C++']