mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 03:33:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			40 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			40 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<p>我们有 <code>n</code> 种不同的贴纸。每个贴纸上都有一个小写的英文单词。</p>
 | 
						||
 | 
						||
<p>您想要拼写出给定的字符串 <code>target</code> ,方法是从收集的贴纸中切割单个字母并重新排列它们。如果你愿意,你可以多次使用每个贴纸,每个贴纸的数量是无限的。</p>
 | 
						||
 | 
						||
<p>返回你需要拼出 <code>target</code> 的最小贴纸数量。如果任务不可能,则返回 <code>-1</code> 。</p>
 | 
						||
 | 
						||
<p><strong>注意:</strong>在所有的测试用例中,所有的单词都是从 <code>1000</code> 个最常见的美国英语单词中随机选择的,并且 <code>target</code> 被选择为两个随机单词的连接。</p>
 | 
						||
 | 
						||
<p> </p>
 | 
						||
 | 
						||
<p><strong>示例 1:</strong></p>
 | 
						||
 | 
						||
<pre>
 | 
						||
<strong>输入:</strong> stickers = ["with","example","science"], target = "thehat"
 | 
						||
<b>输出:</b>3
 | 
						||
<strong>解释:
 | 
						||
</strong>我们可以使用 2 个 "with" 贴纸,和 1 个 "example" 贴纸。
 | 
						||
把贴纸上的字母剪下来并重新排列后,就可以形成目标 “thehat“ 了。
 | 
						||
此外,这是形成目标字符串所需的最小贴纸数量。
 | 
						||
</pre>
 | 
						||
 | 
						||
<p><strong>示例 2:</strong></p>
 | 
						||
 | 
						||
<pre>
 | 
						||
<b>输入:</b>stickers = ["notice","possible"], target = "basicbasic"
 | 
						||
<b>输出:</b>-1
 | 
						||
<strong>解释:</strong>我们不能通过剪切给定贴纸的字母来形成目标“basicbasic”。</pre>
 | 
						||
 | 
						||
<p> </p>
 | 
						||
 | 
						||
<p><strong>提示:</strong></p>
 | 
						||
 | 
						||
<ul>
 | 
						||
	<li><code>n == stickers.length</code></li>
 | 
						||
	<li><code>1 <= n <= 50</code></li>
 | 
						||
	<li><code>1 <= stickers[i].length <= 10</code></li>
 | 
						||
	<li><code>1 <= target <= 15</code></li>
 | 
						||
	<li><code>stickers[i]</code> 和 <code>target</code> 由小写英文单词组成</li>
 | 
						||
</ul>
 |