mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 19:53:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			43 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			43 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>'?'</code> and <code>'*'</code> where:</p>
 | 
						|
 | 
						|
<ul>
 | 
						|
	<li><code>'?'</code> Matches any single character.</li>
 | 
						|
	<li><code>'*'</code> Matches any sequence of characters (including the empty sequence).</li>
 | 
						|
</ul>
 | 
						|
 | 
						|
<p>The matching should cover the <strong>entire</strong> input string (not partial).</p>
 | 
						|
 | 
						|
<p> </p>
 | 
						|
<p><strong>Example 1:</strong></p>
 | 
						|
 | 
						|
<pre>
 | 
						|
<strong>Input:</strong> s = "aa", p = "a"
 | 
						|
<strong>Output:</strong> false
 | 
						|
<strong>Explanation:</strong> "a" does not match the entire string "aa".
 | 
						|
</pre>
 | 
						|
 | 
						|
<p><strong>Example 2:</strong></p>
 | 
						|
 | 
						|
<pre>
 | 
						|
<strong>Input:</strong> s = "aa", p = "*"
 | 
						|
<strong>Output:</strong> true
 | 
						|
<strong>Explanation:</strong> '*' matches any sequence.
 | 
						|
</pre>
 | 
						|
 | 
						|
<p><strong>Example 3:</strong></p>
 | 
						|
 | 
						|
<pre>
 | 
						|
<strong>Input:</strong> s = "cb", p = "?a"
 | 
						|
<strong>Output:</strong> false
 | 
						|
<strong>Explanation:</strong> '?' matches 'c', but the second letter is 'a', which does not match 'b'.
 | 
						|
</pre>
 | 
						|
 | 
						|
<p> </p>
 | 
						|
<p><strong>Constraints:</strong></p>
 | 
						|
 | 
						|
<ul>
 | 
						|
	<li><code>0 <= s.length, p.length <= 2000</code></li>
 | 
						|
	<li><code>s</code> contains only lowercase English letters.</li>
 | 
						|
	<li><code>p</code> contains only lowercase English letters, <code>'?'</code> or <code>'*'</code>.</li>
 | 
						|
</ul>
 |