mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 11:43:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			38 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			38 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<p>给你一个非负整数数组 <code>nums</code> 。在一步操作中,你必须:</p>
 | 
						||
 | 
						||
<ul>
 | 
						||
	<li>选出一个正整数 <code>x</code> ,<code>x</code> 需要小于或等于 <code>nums</code> 中 <strong>最小</strong> 的 <strong>非零</strong> 元素。</li>
 | 
						||
	<li><code>nums</code> 中的每个正整数都减去 <code>x</code>。</li>
 | 
						||
</ul>
 | 
						||
 | 
						||
<p>返回使 <code>nums</code> 中所有元素都等于<em> </em><code>0</code> 需要的 <strong>最少</strong> 操作数。</p>
 | 
						||
 | 
						||
<p> </p>
 | 
						||
 | 
						||
<p><strong>示例 1:</strong></p>
 | 
						||
 | 
						||
<pre>
 | 
						||
<strong>输入:</strong>nums = [1,5,0,3,5]
 | 
						||
<strong>输出:</strong>3
 | 
						||
<strong>解释:</strong>
 | 
						||
第一步操作:选出 x = 1 ,之后 nums = [0,4,0,2,4] 。
 | 
						||
第二步操作:选出 x = 2 ,之后 nums = [0,2,0,0,2] 。
 | 
						||
第三步操作:选出 x = 2 ,之后 nums = [0,0,0,0,0] 。</pre>
 | 
						||
 | 
						||
<p><strong>示例 2:</strong></p>
 | 
						||
 | 
						||
<pre>
 | 
						||
<strong>输入:</strong>nums = [0]
 | 
						||
<strong>输出:</strong>0
 | 
						||
<strong>解释:</strong>nums 中的每个元素都已经是 0 ,所以不需要执行任何操作。
 | 
						||
</pre>
 | 
						||
 | 
						||
<p> </p>
 | 
						||
 | 
						||
<p><strong>提示:</strong></p>
 | 
						||
 | 
						||
<ul>
 | 
						||
	<li><code>1 <= nums.length <= 100</code></li>
 | 
						||
	<li><code>0 <= nums[i] <= 100</code></li>
 | 
						||
</ul>
 |