Pure Combinatorics !! Time(log(n)) Space(1)
Approach\n26^n - |A U B U C|\nA = n-length string which don\'t have l = 25^n\nB = n-length string which don\'t have two e\'s = (1e) + (0e) = n25^(n-1) + 25^n\nC
# Approach\n26^n - |A U B U C|\nA = n-length string which don\'t have l = 25^n\nB = n-length string which don\'t have two e\'s = (1e) + (0e) = n*25^(n-1) + 25^n\nC = n-length string which don\'t have t = 25^n\nA \u2229 B = (no l but 1 e) + (no l and no e) = n*24^(n-1) + 24^n\nB \u2229 C = (no t but 1 e) + (no t and no e) = n*24^(n-1) + 24^n\nA \u2229 C = 24^n\nA \u2229 B \u2229 C =  =  (no l , no t, 1 e) + (no l , no t, no e) = n*23^(n-1) + 23^n \n- Power function can be implemented in linear fashion or binary exponentitation fashion(below).\n\n# Complexity\n- Time complexity: O(log(n)) //for power function\n\n- Space complexity: O(1)\n\n# Code\n```\nclass Solution {\npublic:\n\n    long long power(long long base, int exponent,long long M){\n        if(exponent==0)return 1;\n        if(exponent%2==1){\n            return (base*power((base*base)%M,(exponent-1)/2,M))%M;\n        }\n        return power((base*base)%M,exponent/2,M)%M;\n\n    }\n\n    int stringCount(int n) {\n        long long M = 1e9 + 7;\n        long long total = power(26,n,M)%M;\n        long long A = power(25,n,M)%M;\n        long long B = (n*power(25,n-1,M) + power(25,n,M))%M;\n        long long C = power(25,n,M)%M;\n        long long AinB = (n*power(24,n-1,M) + power(24,n,M))%M;\n        long long BinC= (n*power(24,n-1,M) + power(24,n,M))%M;\n        long long AinC = power(24,n,M)%M;\n        long long AinBinC = (n*power(23,n-1,M) + power(23,n,M))%M;\n        long long Union = (A + B + C + AinBinC - AinB - BinC - AinC)%M;\n        return (total - Union+M)%M;\n    }\n};\n```
['Math', 'Combinatorics', 'C++']