mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 11:43:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			35 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<p>森林中有未知数量的兔子。提问其中若干只兔子<strong> "还有多少只兔子与你(指被提问的兔子)颜色相同?"</strong> ,将答案收集到一个整数数组 <code>answers</code> 中,其中 <code>answers[i]</code> 是第 <code>i</code> 只兔子的回答。</p>
 | 
						||
 | 
						||
<p>给你数组 <code>answers</code> ,返回森林中兔子的最少数量。</p>
 | 
						||
 | 
						||
<p> </p>
 | 
						||
 | 
						||
<p><strong>示例 1:</strong></p>
 | 
						||
 | 
						||
<pre>
 | 
						||
<strong>输入:</strong>answers = [1,1,2]
 | 
						||
<strong>输出:</strong>5
 | 
						||
<strong>解释:</strong>
 | 
						||
两只回答了 "1" 的兔子可能有相同的颜色,设为红色。 
 | 
						||
之后回答了 "2" 的兔子不会是红色,否则他们的回答会相互矛盾。
 | 
						||
设回答了 "2" 的兔子为蓝色。 
 | 
						||
此外,森林中还应有另外 2 只蓝色兔子的回答没有包含在数组中。 
 | 
						||
因此森林中兔子的最少数量是 5 只:3 只回答的和 2 只没有回答的。
 | 
						||
</pre>
 | 
						||
 | 
						||
<p><strong>示例 2:</strong></p>
 | 
						||
 | 
						||
<pre>
 | 
						||
<strong>输入:</strong>answers = [10,10,10]
 | 
						||
<strong>输出:</strong>11
 | 
						||
</pre>
 | 
						||
 | 
						||
<p> </p>
 | 
						||
 | 
						||
<p><strong>提示:</strong></p>
 | 
						||
 | 
						||
<ul>
 | 
						||
	<li><code>1 <= answers.length <= 1000</code></li>
 | 
						||
	<li><code>0 <= answers[i] < 1000</code></li>
 | 
						||
</ul>
 |