mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-13 11:21:42 +08:00
add leetcode problem-cn part6
This commit is contained in:
56
算法题(国内版)/problem (Chinese)/通配符匹配 [wildcard-matching].html
Normal file
56
算法题(国内版)/problem (Chinese)/通配符匹配 [wildcard-matching].html
Normal file
@@ -0,0 +1,56 @@
|
||||
<p>给定一个字符串 (<code>s</code>) 和一个字符模式 (<code>p</code>) ,实现一个支持 <code>'?'</code> 和 <code>'*'</code> 的通配符匹配。</p>
|
||||
|
||||
<pre>'?' 可以匹配任何单个字符。
|
||||
'*' 可以匹配任意字符串(包括空字符串)。
|
||||
</pre>
|
||||
|
||||
<p>两个字符串<strong>完全匹配</strong>才算匹配成功。</p>
|
||||
|
||||
<p><strong>说明:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>s</code> 可能为空,且只包含从 <code>a-z</code> 的小写字母。</li>
|
||||
<li><code>p</code> 可能为空,且只包含从 <code>a-z</code> 的小写字母,以及字符 <code>?</code> 和 <code>*</code>。</li>
|
||||
</ul>
|
||||
|
||||
<p><strong>示例 1:</strong></p>
|
||||
|
||||
<pre><strong>输入:</strong>
|
||||
s = "aa"
|
||||
p = "a"
|
||||
<strong>输出:</strong> false
|
||||
<strong>解释:</strong> "a" 无法匹配 "aa" 整个字符串。</pre>
|
||||
|
||||
<p><strong>示例 2:</strong></p>
|
||||
|
||||
<pre><strong>输入:</strong>
|
||||
s = "aa"
|
||||
p = "*"
|
||||
<strong>输出:</strong> true
|
||||
<strong>解释:</strong> '*' 可以匹配任意字符串。
|
||||
</pre>
|
||||
|
||||
<p><strong>示例 3:</strong></p>
|
||||
|
||||
<pre><strong>输入:</strong>
|
||||
s = "cb"
|
||||
p = "?a"
|
||||
<strong>输出:</strong> false
|
||||
<strong>解释:</strong> '?' 可以匹配 'c', 但第二个 'a' 无法匹配 'b'。
|
||||
</pre>
|
||||
|
||||
<p><strong>示例 4:</strong></p>
|
||||
|
||||
<pre><strong>输入:</strong>
|
||||
s = "adceb"
|
||||
p = "*a*b"
|
||||
<strong>输出:</strong> true
|
||||
<strong>解释:</strong> 第一个 '*' 可以匹配空字符串, 第二个 '*' 可以匹配字符串 "dce".
|
||||
</pre>
|
||||
|
||||
<p><strong>示例 5:</strong></p>
|
||||
|
||||
<pre><strong>输入:</strong>
|
||||
s = "acdcb"
|
||||
p = "a*c?b"
|
||||
<strong>输出:</strong> false</pre>
|
Reference in New Issue
Block a user