C++ || Memorization || Easy to Understand
Intuition:\nImagine arranging lowercase alphabets in a string of length \'n\' while ensuring the string remains valid. To find the number of valid arrangements,
***Intuition:***\nImagine arranging lowercase alphabets in a string of length \'n\' while ensuring the string remains valid. To find the number of valid arrangements, consider determining the choices available at each position (\'i-th\' index). You have the freedom to choose 23 alphabets (no constraints), excluding \'l\', \'e\', and \'t\' at each index. Once \'l\' is selected at least once, \'e\' is chosen at least twice, or \'t\' is picked at least once, their respective constraints are satisfied. If all three constraints are fulfilled, the string is considered valid. Dynamic programming, represented by a 4D array, efficiently manages repetitive states in this process.\n\n***Algorithm:***\n1. Initialize a 4D dynamic programming array.\n2. At any index, you can freely pick from 23 alphabets (excluding \'l\', \'e\', and \'t\').\n3. Adjust counts of  \'l\', \'e\' and \'t\' whenever they are selected (upto their respective constraint).\n4. Iterate through the string positions, updating counts based on the choices and constraints.\n5. At last when index >= n, check if all constraints are satisfied as a base case.\n\n```\nclass Solution {\npublic:\n    \n    int stringCount(int n) {\n        int dp[n][2][3][2];\n        memset(dp,-1,sizeof(dp));\n        \n        function<int(int,int,int,int)> solve=[&](int i, int l,int e, int t){\n            if(i>=n)return int(l==1&&e==2&&t==1);\n            if(dp[i][l][e][t]!=-1)return dp[i][l][e][t];\n            \n            long long ans=0,mod=1e9+7,mul=23;\n\t\t\t\n\t\t\t// mul represents number of alphabets you are free to choose\n            if(l==1)mul++;\n            if(e==2)mul++;\n            if(t==1)mul++;\n            \n            ans+=mul*solve(i+1,l,e,t);\n            ans%=mod;\n            \n            if(l<1)ans+=solve(i+1,1,e,t);\n            ans%=mod;\n            \n            if(e<2)ans+=solve(i+1,l,e+1,t);\n            ans%=mod;\n            \n            if(t<1)ans+=solve(i+1,l,e,1);\n            ans%=mod;\n            \n            return dp[i][l][e][t]=ans;\n            \n        };\n        \n        return solve(0,0,0,0);\n    }\n};\n```
['C']