Intuitive Simple Solution🔥+ Video Solution | Recursion + DP ✅|  Easy to understand
Intuition\n Describe your first thoughts on how to solve this problem. \nWe fill think recursively and then optimise it with dynamic programming.\n\n# Video Sol
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nWe fill think recursively and then optimise it with dynamic programming.\n\n# Video Solution and Explanation\nhttps://youtu.be/j8HWDesrlTc\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. For every position fromt 1 to n we will fit characters from \'a\' to \'z\'.\n2. For next position we will pass n-1 and when it becomes 0 we will simply check whether `count of l>=1 and count of e>=2 and count of t>=1` or not.\n3. If yes we wil return 1 else 0.\n4. And while backtracking we will add up the number of ways in ans.\n\nFor memoization:\n1. We can see: \n    -> There are 2 required occurence/values for \'l\', i.e, 0 or 1 times\n    -> There are 2 required occurence/values for \'e\', i.e, 0 or 1 or 2 times\n    -> There are 2 required occurence/values for \'t\', i.e, 0 or 1 times\n\nThus we will take a dp of dimension `n*2*3*2`;\n# Complexity\n- Time complexity: Doesn\'t matter in contests\n<!-- Add your time complexity here, e.g. $$O(n)$$ --> \n\n- Space complexity: Doesn\'t matter in contests\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int mod = 1e9+7;\n\tint solve(int n, vector<int> &count, vector<vector<vector<vector<int>>>> &dp){\n\t\tif(n==0){\n\t\t\treturn count[0]>=1 and count[1]>=2 and count[2]>=1;\n\t\t}\n\t\tint &ali = dp[n][count[0]][count[1]][count[2]];\n\t\tif(ali!=-1) return ali;\n\t\tint ans =0;\n\t\tfor(char c=\'a\'; c<=\'z\'; c++){\n\t\t\tbool flg1=false, flg2=false, flg3=false;\n\t\t\tif(c==\'l\' and count[0]<1){flg1=true; count[0]++;}\n        \telse if(c==\'e\' and count[1]<2){flg2=true; count[1]++;}\n        \telse if(c==\'t\' and count[2]<1){flg3=true; count[2]++;}\n\t\t\tans += (solve(n-1, count, dp))%mod;\n        \tans%=mod;\n\t\t\tif(flg1) count[0]--;\n        \tif(flg2) count[1]--;\n        \tif(flg3) count[2]--;\n\t\t}\n\t\treturn ali = ans%mod;\n\t}\n\n    int stringCount(int n) {\n    \tvector<int> count(3);\n        int ans=0;\n\n        vector<vector<vector<vector<int>>>> dp(n+1, vector<vector<vector<int>>> (2, vector<vector<int>> (3, vector<int> (2, -1))));\n\n        for(char c=\'a\'; c<=\'z\'; c++){\n        \tif(c==\'l\') count[0]++;\n        \telse if(c==\'e\') count[1]++;\n        \telse if(c==\'t\') count[2]++;\n        \tans += (solve(n-1, count, dp))%mod;\n        \tans%=mod;\n        \tif(c==\'l\') count[0]--;\n        \telse if(c==\'e\') count[1]--;\n        \telse if(c==\'t\') count[2]--;\n        }\n        return ans%mod;\n    }\n};\n```
['Array', 'Dynamic Programming', 'Recursion', 'C++']