Simple Java Code 0 ms beats 100 %
\n# Complexity\n\n# Code\n\nclass Solution {\n    private final static long MOD = (long) ((1e9) + 7);\n    public int stringCount(int n) {\n        return (int)
\n# Complexity\n![image.png](https://assets.leetcode.com/users/images/0e610754-6fbc-446f-bacd-1ab8bc47eefc_1715010174.2553346.png)\n# Code\n```\nclass Solution {\n    private final static long MOD = (long) ((1e9) + 7);\n    public int stringCount(int n) {\n        return (int) ((power(26, n)  -  ((power(25, n - 1) * (n + 75)) % MOD -  (power(24, n - 1) * (n * 2 + 72)) % MOD  +  (power(23, n - 1) * (n + 23)) % MOD  + MOD) % MOD  + MOD) % MOD);\n    }\n    private static long power(long a, long b) {\n        long result = 1;\n        while (b > 0) {\n            if ((b & 1) == 1)    result = (result * a) % MOD;\n            b >>= 1;\n            a = (a * a) % MOD;\n        }\n        return result;\n    }\n}\n```
['Math', 'Combinatorics', 'Java']