mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
41 lines
1.9 KiB
HTML
41 lines
1.9 KiB
HTML
<p>给你两个长度为 <code>n</code> 的字符串 <code>s1</code> 和 <code>s2</code> ,以及一个字符串 <code>evil</code> 。请你返回 <strong>好字符串 </strong>的数目。</p>
|
||
|
||
<p><strong>好字符串</strong> 的定义为:它的长度为 <code>n</code> ,字典序大于等于 <code>s1</code> ,字典序小于等于 <code>s2</code> ,且不包含 <code>evil</code> 为子字符串。</p>
|
||
|
||
<p>由于答案可能很大,请你返回答案对 10^9 + 7 取余的结果。</p>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>示例 1:</strong></p>
|
||
|
||
<pre><strong>输入:</strong>n = 2, s1 = "aa", s2 = "da", evil = "b"
|
||
<strong>输出:</strong>51
|
||
<strong>解释:</strong>总共有 25 个以 'a' 开头的好字符串:"aa","ac","ad",...,"az"。还有 25 个以 'c' 开头的好字符串:"ca","cc","cd",...,"cz"。最后,还有一个以 'd' 开头的好字符串:"da"。
|
||
</pre>
|
||
|
||
<p><strong>示例 2:</strong></p>
|
||
|
||
<pre><strong>输入:</strong>n = 8, s1 = "leetcode", s2 = "leetgoes", evil = "leet"
|
||
<strong>输出:</strong>0
|
||
<strong>解释:</strong>所有字典序大于等于 s1 且小于等于 s2 的字符串都以 evil 字符串 "leet" 开头。所以没有好字符串。
|
||
</pre>
|
||
|
||
<p><strong>示例 3:</strong></p>
|
||
|
||
<pre><strong>输入:</strong>n = 2, s1 = "gx", s2 = "gz", evil = "x"
|
||
<strong>输出:</strong>2
|
||
</pre>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>提示:</strong></p>
|
||
|
||
<ul>
|
||
<li><code>s1.length == n</code></li>
|
||
<li><code>s2.length == n</code></li>
|
||
<li><code>s1 <= s2</code></li>
|
||
<li><code>1 <= n <= 500</code></li>
|
||
<li><code>1 <= evil.length <= 50</code></li>
|
||
<li>所有字符串都只包含小写英文字母。</li>
|
||
</ul>
|