mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 11:43:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			30 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			30 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<p>你有一个单词列表 <code>words</code> 和一个模式  <code>pattern</code>,你想知道 <code>words</code> 中的哪些单词与模式匹配。</p>
 | 
						|
 | 
						|
<p>如果存在字母的排列 <code>p</code> ,使得将模式中的每个字母 <code>x</code> 替换为 <code>p(x)</code> 之后,我们就得到了所需的单词,那么单词与模式是匹配的。</p>
 | 
						|
 | 
						|
<p><em>(回想一下,字母的排列是从字母到字母的双射:每个字母映射到另一个字母,没有两个字母映射到同一个字母。)</em></p>
 | 
						|
 | 
						|
<p>返回 <code>words</code> 中与给定模式匹配的单词列表。</p>
 | 
						|
 | 
						|
<p>你可以按任何顺序返回答案。</p>
 | 
						|
 | 
						|
<p> </p>
 | 
						|
 | 
						|
<p><strong>示例:</strong></p>
 | 
						|
 | 
						|
<pre><strong>输入:</strong>words = ["abc","deq","mee","aqq","dkd","ccc"], pattern = "abb"
 | 
						|
<strong>输出:</strong>["mee","aqq"]
 | 
						|
<strong>解释:
 | 
						|
</strong>"mee" 与模式匹配,因为存在排列 {a -> m, b -> e, ...}。
 | 
						|
"ccc" 与模式不匹配,因为 {a -> c, b -> c, ...} 不是排列。
 | 
						|
因为 a 和 b 映射到同一个字母。</pre>
 | 
						|
 | 
						|
<p> </p>
 | 
						|
 | 
						|
<p><strong>提示:</strong></p>
 | 
						|
 | 
						|
<ul>
 | 
						|
	<li><code>1 <= words.length <= 50</code></li>
 | 
						|
	<li><code>1 <= pattern.length = words[i].length <= 20</code></li>
 | 
						|
</ul>
 |