Number of Strings Which Can Be Rearranged to Contain Substring

You are given an integer n.

A string s is called good if it contains only lowercase English characters and it is possible to rearrange the characters of s such that the new string contains "leet" as a substring.

Return the total number of good strings of length n.

Since the answer may be large, return it modulo 10^9 + 7.

A substring is a contiguous sequence of characters within a string.

Example 1
Inputn = 4
Output12
The 12 strings which can be rearranged to have "leet" as a substring are: "eelt", "eetl", "elet", "elte", "etel", "etle", "leet", "lete", "ltee", "teel", "tele", and "tlee".
Example 2
Inputn = 10
Output83943898
The number of strings with length 10 which can be rearranged to have "leet" as a substring is 526083947580, so the answer is 526083947580 % (10^9 + 7) = 83943898.

Constraints

  • 1 <= n <= 10^5

Asked at 1 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate