Will only take 10 seconds to understand & 4D Memoization & Recursion
Intuition\n Describe your first thoughts on how to solve this problem. \nInstead of trying every single possible character I just multiplied it by (26-k) to mak
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nInstead of trying every single possible character I just multiplied it by (26-k) to make it easier.\n# Approach\n<!-- Describe your approach to solving the problem. -->\nMy approach is basicly recursion with 4D memoization\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n    O(N)\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n    O(N)\n# Code\n```java []\nclass Solution {\n    int MOD = 1000000007;\n    public int stringCount(int n) {\n        Long[][][][] dp = new Long[n][3][2][2];\n        \n        return (int)(f(n,0,0,0,0,dp) % MOD);\n    }\n    public long f(int n,int e,int l,int t,int count,Long[][][][] dp){\n        if(count >= n){\n            if(e >= 2 && l >= 1 && t >= 1){\n                return 1;\n            }\n            return 0;\n        }\n        if(dp[count][e][l][t] != null){\n            return dp[count][e][l][t];\n        }\n        long result = 0;\n        int k = 0;\n        if(e < 2){\n            result += f(n,e+1,l,t,count+1,dp) % MOD;\n            k++;\n        }\n        if(l < 1){\n            result += f(n,e,l+1,t,count+1,dp) % MOD;\n            k++;\n        }\n        if(t < 1){\n            result += f(n,e,l,t+1,count+1,dp) % MOD;\n            k++;\n        }\n        result += ((f(n,e,l,t,count+1,dp)%MOD) * (26 - k)) % MOD;\n        return dp[count][e][l][t] = result;\n    }\n}\n```
['Math', 'Dynamic Programming', 'Recursion', 'Memoization', 'C++', 'Java', 'Python3']