1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-27 10:40:26 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/子字符串匹配模式 [substring-matching-pattern].html

55 lines
2.0 KiB
HTML
Raw Normal View History

2025-01-09 01:30:35 +08:00
<p>给你一个字符串&nbsp;<code>s</code>&nbsp;和一个模式字符串&nbsp;<code>p</code>&nbsp;,其中&nbsp;<code>p</code> <strong>恰好</strong>&nbsp;包含 <strong>一个</strong>&nbsp;<code>'*'</code>&nbsp;符号。</p>
<p><code>p</code>&nbsp;中的 <code>'*'</code>&nbsp;符号可以被替换为零个或多个字符组成的任意字符序列。</p>
<p>如果 <code>p</code>&nbsp;可以变成 <code>s</code>&nbsp;<span data-keyword="substring-nonempty">子字符串</span>,那么返回&nbsp;<code>true</code>&nbsp;,否则返回 <code>false</code>&nbsp;</p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<div class="example-block">
<p><span class="example-io"><b>输入:</b>s = "leetcode", p = "ee*e"</span></p>
<p><span class="example-io"><b>输出:</b>true</span></p>
<p><b>解释:</b></p>
<p>&nbsp;<code>'*'</code>&nbsp;替换为&nbsp;<code>"tcod"</code>&nbsp;,子字符串&nbsp;<code>"eetcode"</code>&nbsp;匹配模式串。</p>
</div>
<p><strong class="example">示例 2</strong></p>
<div class="example-block">
<p><span class="example-io"><b>输入:</b>s = "car", p = "c*v"</span></p>
<p><span class="example-io"><b>输出:</b>false</span></p>
<p><strong>解释:</strong></p>
<p>不存在匹配模式串的子字符串。</p>
</div>
<p><strong class="example">示例 3</strong></p>
<div class="example-block">
<p><span class="example-io"><b>输入:</b>s = "luck", p = "u*"</span></p>
<p><span class="example-io"><b>输出:</b>true</span></p>
<p><b>解释:</b></p>
<p>子字符串&nbsp;<code>"u"</code>&nbsp;<code>"uc"</code>&nbsp;&nbsp;<code>"uck"</code>&nbsp;都匹配模式串。</p>
</div>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= s.length &lt;= 50</code></li>
<li><code>1 &lt;= p.length &lt;= 50 </code></li>
<li><code>s</code>&nbsp;只包含小写英文字母。</li>
<li><code>p</code>&nbsp;只包含小写英文字母和一个&nbsp;<code>'*'</code> 符号。</li>
</ul>