ee
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nimport java.util.*;\n\n\nclass Solution {\n\n    // N = 5;\n    // _,l,e,e,t  chosen this permutation; 26 choices for 1st letter;\n    // l,_,e,e,t\n    // l,e,_,e,t\n    // l,e,e,_,t\n    // l,e,e,t,_\n\n    // but also need to consider the permutations WITHIN "leet"  12 total:\n    // l,e,e,t\n    // l,e,t,e\n    // l,t,e,e\n\n    // t,e,e,l\n    // t,e,l,e\n    // t,l,e,e\n\n    // e,e,l,t\n    // e,e,t,l\n    // e,t,e,l\n    // e,l,e,t\n    // e,t,l,e\n    // e,l,t,e\n\n    // len N\n    // 4 of these need to be: l e e t; (N - 4) can be any of the 26 letters\n    // the 4 special can be arranged in any way; and mixed with the other (N-4)\n    // C(n,4) = number of templates to fill with 26 options for each empty space:\n    // _,_,l,e,e,t,_,_ ...\n    // HOWEVER THIS DOES NOT WORK BECAUSE IT LEADS TO DUPLICATES !!!!!!!!!!!\n    // if we put "e" on the leftmost place and keep the same locked "leet" it is the same\n    // as putting "e" from leet at 1st index and unlocking 26 possibilities for the 4th index\n\n    // Try another thing: all possible combinations (26^N) - INVALID ones:\n    // INVALID COMBS: missing: 1 L, 1 T, 2 E\n    // combs without L  = A\n    // combs without T  = B\n    // combs without 2E = C\n\n    // INCLUSION-EXCLUSION PRINCIPLE: for all INVALID\n    // \u2223A \u222A B \u222A C\u2223=\u2223A\u2223+\u2223B\u2223+\u2223C\u2223\u2212\u2223A \u2229 B\u2223\u2212\u2223B \u2229 C\u2223\u2212\u2223C \u2229 A\u2223+\u2223A \u2229 B \u2229 C\u2223\n\n    // Number of Strings with:\n    // 0E = 25^N\n    // 1E = C(n,1) * 25^(N - 1) = N * 25^(N-1)   choose 1E position; rest is all possibilities\n\n    public int stringCount(int n) {\n        long pow23n1 = pow(23, n - 1);\n        long pow23n = mul(pow23n1, 23);\n        long pow24n1 = pow(24, n - 1);\n        long pow24n = mul(pow24n1, 24);\n        long pow25n1 = pow(25, n - 1);\n        long pow25n = mul(pow25n1, 25);\n\n        long all = pow(26, n);\n        long withoutOne = pow25n; // A,B same without 1 letter\n        long without2E = sum(pow25n, mul(n, pow25n1)); // without 2 E\n        long withoutTwo = pow24n; // without L and T\n\n        long withoutOneAndE = sum(pow24n, mul(n, pow24n1)); // no L/T and E < 2 = (0L/T and 0E) + (0L/T + 1E)\n        long abc = sum(pow23n, mul(n, pow23n1)); // no L, no T, max 1E = no L,T,E + no L,T and 1 E\n        long invalid = sum(sum(withoutOne, withoutOne), without2E);\n        long invalidSub = sum(sum(withoutTwo, withoutOneAndE), withoutOneAndE);\n        invalid = (invalid - invalidSub + M) % M;\n        invalid = (invalid + abc) % M;\n        return (int) (all - invalid + M) % M;\n    }\n\n\n    // IDEA 2: DP build strings char by char and count; count only valid ones !!!!\n    // dp[i][l][t][e] = num words with i letters and AT LEAST l Ls t Ts e Es\n//    public int stringCount(int n) {\n//        long[][][][] dp = new long[n + 1][2][2][3];\n//        dp[0][0][0][0] = 1; // base case for DP: 1 way for empty string\n//        for (int i = 1; i <= n; i++) { // solve for length i\n//            for (int l = 0; l <= 1; l++) { // solve for L 0..1\n//                for (int t = 0; t <= 1; t++) { // solve for T 0..1\n//                    for (int e = 0; e <= 2; e++) { // solve for E 0..2\n//\n//                        for (int k = 0; k < 26; k++) { // add each of the 26 letters in alphabet\n//                            if (k == 0 && l > 0) { // add L\n//                                dp[i][l][t][e] += dp[i - 1][l - 1][t][e];\n//                            } else if (k == 1 && t > 0) { // add T\n//                                dp[i][l][t][e] += dp[i - 1][l][t - 1][e];\n//                            } else if (k == 2 && e > 0) {// add E\n//                                dp[i][l][t][e] += dp[i - 1][l][t][e - 1];\n//                            } else {// add anything else\n//                                dp[i][l][t][e] += dp[i - 1][l][t][e]; // another version of prev len string\n//                            }\n//                            dp[i][l][t][e] %= M;\n//                        }\n//                    }\n//                }\n//            }\n//        }\n//        return (int) dp[n][1][1][2];\n//    }\n\n\n    long mul(long a, long b) {\n        return (a * b) % M;\n    }\n\n    long sum(long a, long b) {\n        return (a + b) % M;\n    }\n\n    long pow(int a, int b) {\n        if (b == 0) return 1;\n        long ab2 = pow(a, b / 2);\n        ab2 = (ab2 * ab2) % M;\n        if (b % 2 == 1) ab2 = (ab2 * a) % M;\n        return ab2;\n    }\n\n    int M = (int) 1e9 + 7;\n\n}\n\n```
['Java']