Python 3 || 2 lines, inclusion/exclusion || T/S: 95% /  100%
\nThis problem is a lot of combinatorics and algebra with a little bit of coding. \n\nWe determine a function f to compute the number of ways to form strings of
\nThis problem is a lot of combinatorics and algebra with a little bit of coding. \n\nWe determine a function `f` to compute the number of ways to form strings of length `n` using a specific a number of characters, `base`. We apply the principle of inclusion-exclusion to determine the result.\n```\nclass Solution:\n    def stringCount(self, n: int, mod = 1_000_000_007) -> int:\n\n        f = lambda base, exp: pow(base, exp, mod) - pow(base-1, exp, mod)\n\n        return (f(26,n) - 2*f(25,n) + f(24,n) - n*f(25,n-1) +n*f(24,n-1)) %mod\n```\n[https://leetcode.com/problems/number-of-strings-which-can-be-rearranged-to-contain-substring/submissions/1096789846/](http://)\n\n\n\nI could be wrong, but I think that time complexity is *O*(log*N*) (because of `pow`) and space complexity is *O*(1), in which *N* ~ `n`.
['Python3']