Explanation , Simple Maths  ,No DP , O( log(n))
Basic Intuition:  \nWe need to construct a string of length \(n\) that includes at least:  \n\n1. One \'l\'  \n2. Two \'e\'s  \n3. One \'t\'  \n\nTo count these
## Basic Intuition:  \nWe need to construct a string of length \\(n\\) that includes at least:  \n\n1. One `\'l\'`  \n2. Two `\'e\'`s  \n3. One `\'t\'`  \n\nTo count these valid strings, we start by calculating all possible strings and then subtracting the invalid ones (those that don\u2019t meet the requirements).  \n\nTotal Possible Strings (U):  \nAll combinations of \\(n\\) characters from an alphabet of 26 letters, i.e.,  \n<img src="http://latex.codecogs.com/svg.image?U%20=%2026^n" />  \n\n### Invalid Conditions:  \nWe subtract strings that violate at least one of the required conditions:  \n\n**Condition A**: \\(l = 0\\) (no `\'l\'`)  \n**Condition B**: \\(t = 0\\) (no `\'t\'`)  \n**Condition C**: \\(e < 2\\) (fewer than 2 `\'e\'`s)  \n\n**Desired Strings**:  \n<img src="http://latex.codecogs.com/svg.image?%5Ctext%7BDesired%20Strings%7D%20=%20U%20-%20%28A%20%5Cor%20B%20%5Cor%20C%29" />  \n\n### Using Inclusion-Exclusion Principle:  \nTo find strings that violate at least one of the conditions (A or B or C), we use the formula:  \n<img src="http://latex.codecogs.com/svg.image?A%20%2B%20B%20%2B%20C%20-%20A%20%5Ccap%20B%20-%20B%20%5Ccap%20C%20-%20C%20%5Ccap%20A%20%2B%20A%20%5Ccap%20B%20%5Ccap%20C" />  \n\n### Calculating Each Term:  \n- **A** (\\(l = 0\\)):  \n  Only 25 characters are available (all characters except `\'l\'`), so there are:  \n  <img src="http://latex.codecogs.com/svg.image?A%20=%2025^n" />  \n\n- **B** (\\(t = 0\\)):  \n  Only 25 characters are available (all characters except `\'t\'`), so there are:  \n  <img src="http://latex.codecogs.com/svg.image?B%20=%2025^n" />  \n\n- **C** (\\(e < 2\\)):  \n  - **Case 1**: \\(e = 0\\), no `\'e\'` character, so there are:  \n    <img src="http://latex.codecogs.com/svg.image?C_%7Be%3D0%7D%20=%2025^n" />  \n  - **Case 2**: \\(e = 1\\), exactly one `\'e\'`. There are \\(n\\) possible positions for this `\'e\'`, and the other \\(n-1\\) positions are filled with any of the other 25 characters, so the number of strings is:  \n    <img src="http://latex.codecogs.com/svg.image?C_%7Be%3D1%7D%20=%20n%20%5Ctimes%2025%5E%7Bn-1%7D" />  \n\n### Intersection Terms:  \n- **A \u2229 B** (\\(l = 0\\) and \\(t = 0\\)):  \n  Only 24 characters are available, so there are:  \n  <img src="http://latex.codecogs.com/svg.image?A%20%5Ccap%20B%20=%2024^n" />  \n\n- **A \u2229 C** (\\(l = 0\\) and \\(e < 2\\)):  \n  - **Case 1**: \\(e = 0\\), no `\'e\'`, so there are:  \n    <img src="http://latex.codecogs.com/svg.image?A%20%5Ccap%20C_%7Be%3D0%7D%20=%2024^n" />  \n  - **Case 2**: \\(e = 1\\), exactly one `\'e\'`. There are \\(n\\) positions for the `\'e\'` and the remaining \\(n-1\\) positions are filled with any of the other 24 characters, so there are:  \n    <img src="http://latex.codecogs.com/svg.image?A%20%5Ccap%20C_%7Be%3D1%7D%20=%20n%20%5Ctimes%2024%5E%7Bn-1%7D" />  \n\n- **B \u2229 C** (\\(t = 0\\) and \\(e < 2\\)):  \n  Same as **A \u2229 C**, yielding:  \n  <img src="http://latex.codecogs.com/svg.image?B%20%5Ccap%20C%20=%2024^n%20%2B%20n%20%5Ctimes%2024%5E%7Bn-1%7D" />  \n\n- **A \u2229 B \u2229 C** (\\(l = 0\\), \\(t = 0\\), and \\(e < 2\\)):  \n  - **Case 1**: \\(e = 0\\), no `\'e\'`, so there are:  \n    <img src="http://latex.codecogs.com/svg.image?A%20%5Ccap%20B%20%5Ccap%20C_%7Be%3D0%7D%20=%2023^n" />  \n  - **Case 2**: \\(e = 1\\), exactly one `\'e\'`. There are \\(n\\) positions for the `\'e\'` and the remaining \\(n-1\\) positions are filled with any of the other 23 characters, so there are:  \n    <img src="http://latex.codecogs.com/svg.image?A%20%5Ccap%20B%20%5Ccap%20C_%7Be%3D1%7D%20=%20n%20%5Ctimes%2023%5E%7Bn-1%7D" />  \n\n### Final Calculation:  \nSubstitute these values into the inclusion-exclusion formula to find the count of valid strings:  \n<img src="http://latex.codecogs.com/svg.image?%5Ctext%7BValid%20Strings%7D%20=%20U%20-%20%28A%20%2B%20B%20%2B%20C%20-%20A%20%5Ccap%20B%20-%20B%20%5Ccap%20C%20-%20C%20%5Ccap%20A%20%2B%20A%20%5Ccap%20B%20%5Ccap%20C%29" />  \n\nThis approach ensures that all invalid cases are considered, allowing us to find the number of valid strings efficiently.  \n\n\n```\n#define ll long long\n\nclass Solution {\npublic:\n    ll p = 1e9 + 7; \n\n    \n    ll pow(ll x, ll y, ll p) {\n        ll res = 1;\n        x = x % p; \n        if (x == 0) return 0;\n        while (y > 0) {\n            if (y & 1) res = (res * x) % p; \n            y = y >> 1; \n            x = (x * x) % p; \n        }\n        return res;\n    }\n\n    int stringCount(int n) {\n        ll ans = pow(26, n, p);\n        ll sub = (2 * pow(25, n, p)) % p; // Cases for t=0 or l=0\n        sub = (sub + (pow(25, n, p) + n * pow(25, n - 1, p) % p) % p) % p; // Cases for e=0 or e=1\n        sub = (sub - pow(24, n, p) + p) % p; // Case for t=0 and l=0\n        sub = (sub - (pow(24, n, p) + n * pow(24, n - 1, p) % p) % p + p) % p; // Cases for t=0 & e<2 || l=0 & e<2\n        sub = (sub - (pow(24, n, p) + n * pow(24, n - 1, p) % p) % p + p) % p;\n        sub = (sub + (pow(23, n, p) + n * pow(23, n - 1, p) % p) % p) % p; // Final case\n        return (ans - sub + p) % p;\n    }\n};\n\n```\n
['Math', 'C']