<p>You are given an integer <code>n</code>.</p>

<p>A string <code>s</code> is called <strong>good </strong>if it contains only lowercase English characters <strong>and</strong> it is possible to rearrange the characters of <code>s</code> such that the new string contains <code>&quot;leet&quot;</code> as a <strong>substring</strong>.</p>

<p>For example:</p>

<ul>
	<li>The string <code>&quot;lteer&quot;</code> is good because we can rearrange it to form <code>&quot;leetr&quot;</code> .</li>
	<li><code>&quot;letl&quot;</code> is not good because we cannot rearrange it to contain <code>&quot;leet&quot;</code> as a substring.</li>
</ul>

<p>Return <em>the <strong>total</strong> number of good strings of length </em><code>n</code>.</p>

<p>Since the answer may be large, return it <strong>modulo </strong><code>10<sup>9</sup> + 7</code>.</p>

<p>A <strong>substring</strong> is a contiguous sequence of characters within a string.</p>

<div class="notranslate" style="all: initial;">&nbsp;</div>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> n = 4
<strong>Output:</strong> 12
<strong>Explanation:</strong> The 12 strings which can be rearranged to have &quot;leet&quot; as a substring are: &quot;eelt&quot;, &quot;eetl&quot;, &quot;elet&quot;, &quot;elte&quot;, &quot;etel&quot;, &quot;etle&quot;, &quot;leet&quot;, &quot;lete&quot;, &quot;ltee&quot;, &quot;teel&quot;, &quot;tele&quot;, and &quot;tlee&quot;.
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> n = 10
<strong>Output:</strong> 83943898
<strong>Explanation:</strong> The number of strings with length 10 which can be rearranged to have &quot;leet&quot; as a substring is 526083947580. Hence the answer is 526083947580 % (10<sup>9</sup> + 7) = 83943898.
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= n &lt;= 10<sup>5</sup></code></li>
</ul>

class Solution:
    def stringCount(self, n: int) -> int:
        MOD = 10**9 + 7

        # dp[x][l][e][t] will store the number of valid strings of length x with l 'l's, e 'e's, and t 't's
        dp = [[[[0] * 2 for _ in range(3)] for _ in range(2)] for _ in range(n + 1)]
        
        # Base case: There's one way to have an empty string (length 0) with 0 'l's, 0 'e's, and 0 't's
        dp[0][0][0][0] = 1
        
        # Fill the dp table
        for x in range(n):
            for l in range(2):
                for e in range(3):
                    for t in range(2):
                        for i in range(26):
                            k = chr(i + ord('a'))
                            if k == 'l' and l < 1:
                                dp[x + 1][l + 1][e][t] = (dp[x + 1][l + 1][e][t] + dp[x][l][e][t]) % MOD
                            elif k == 'e' and e < 2:
                                dp[x + 1][l][e + 1][t] = (dp[x + 1][l][e + 1][t] + dp[x][l][e][t]) % MOD
                            elif k == 't' and t < 1:
                                dp[x + 1][l][e][t + 1] = (dp[x + 1][l][e][t + 1] + dp[x][l][e][t]) % MOD
                            else:
                                dp[x + 1][l][e][t] = (dp[x + 1][l][e][t] + dp[x][l][e][t]) % MOD
        
        # Sum up all the valid strings of length n with at least 1 'l', 2 'e's, and 1 't'
        result = 0
        for l in range(1, 2):
            for e in range(2, 3):
                for t in range(1, 2):
                    result = (result + dp[n][l][e][t]) % MOD
        
        return result

130500