1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/重新排列后包含指定子字符串的字符串数目 [number-of-strings-which-can-be-rearranged-to-contain-substring].html
2023-11-13 00:01:27 +08:00

43 lines
1.8 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给你一个整数&nbsp;<code>n</code>&nbsp;</p>
<p>如果一个字符串&nbsp;<code>s</code>&nbsp;只包含小写英文字母,<strong></strong>&nbsp;<code>s</code>&nbsp;的字符重新排列后,新字符串包含&nbsp;<strong>子字符串</strong>&nbsp;<code>"leet"</code> ,那么我们称字符串 <code>s</code>&nbsp;是一个 <strong></strong>&nbsp;字符串。</p>
<p>比方说:</p>
<ul>
<li>字符串&nbsp;<code>"lteer"</code>&nbsp;是好字符串,因为重新排列后可以得到&nbsp;<code>"leetr"</code>&nbsp;</li>
<li><code>"letl"</code>&nbsp;不是好字符串,因为无法重新排列并得到子字符串&nbsp;<code>"leet"</code>&nbsp;</li>
</ul>
<p>请你返回长度为 <code>n</code>&nbsp;的好字符串 <strong></strong>&nbsp;数目。</p>
<p>由于答案可能很大,将答案对<strong>&nbsp;</strong><code>10<sup>9</sup> + 7</code>&nbsp;<strong>取余</strong>&nbsp;后返回。</p>
<p><strong>子字符串</strong>&nbsp;是一个字符串中一段连续的字符序列。</p>
<div class="notranslate" style="all: initial;">&nbsp;</div>
<p><strong class="example">示例 1</strong></p>
<pre>
<b>输入:</b>n = 4
<b>输出:</b>12
<b>解释:</b>总共有 12 个字符串重新排列后包含子字符串 "leet" "eelt" "eetl" "elet" "elte" "etel" "etle" "leet" "lete" "ltee" "teel" "tele" 和 "tlee" 。
</pre>
<p><strong class="example">示例 2</strong></p>
<pre>
<b>输入:</b>n = 10
<b>输出:</b>83943898
<b>解释:</b>长度为 10 的字符串重新排列后包含子字符串 "leet" 的方案数为 526083947580 。所以答案为 526083947580 % (10<sup>9</sup> + 7) = 83943898 。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= n &lt;= 10<sup>5</sup></code></li>
</ul>