mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 11:43:12 +08:00 
			
		
		
		
	国外版
This commit is contained in:
		
							
								
								
									
										30
									
								
								算法题(国外版)/minimum-moves-to-equal-array-elements.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								算法题(国外版)/minimum-moves-to-equal-array-elements.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,30 @@
 | 
			
		||||
<p>Given an integer array <code>nums</code> of size <code>n</code>, return <em>the minimum number of moves required to make all array elements equal</em>.</p>
 | 
			
		||||
 | 
			
		||||
<p>In one move, you can increment <code>n - 1</code> elements of the array by <code>1</code>.</p>
 | 
			
		||||
 | 
			
		||||
<p> </p>
 | 
			
		||||
<p><strong>Example 1:</strong></p>
 | 
			
		||||
 | 
			
		||||
<pre>
 | 
			
		||||
<strong>Input:</strong> nums = [1,2,3]
 | 
			
		||||
<strong>Output:</strong> 3
 | 
			
		||||
<strong>Explanation:</strong> Only three moves are needed (remember each move increments two elements):
 | 
			
		||||
[1,2,3]  =>  [2,3,3]  =>  [3,4,3]  =>  [4,4,4]
 | 
			
		||||
</pre>
 | 
			
		||||
 | 
			
		||||
<p><strong>Example 2:</strong></p>
 | 
			
		||||
 | 
			
		||||
<pre>
 | 
			
		||||
<strong>Input:</strong> nums = [1,1,1]
 | 
			
		||||
<strong>Output:</strong> 0
 | 
			
		||||
</pre>
 | 
			
		||||
 | 
			
		||||
<p> </p>
 | 
			
		||||
<p><strong>Constraints:</strong></p>
 | 
			
		||||
 | 
			
		||||
<ul>
 | 
			
		||||
	<li><code>n == nums.length</code></li>
 | 
			
		||||
	<li><code>1 <= nums.length <= 10<sup>5</sup></code></li>
 | 
			
		||||
	<li><code>-10<sup>9</sup> <= nums[i] <= 10<sup>9</sup></code></li>
 | 
			
		||||
	<li>The answer is guaranteed to fit in a <strong>32-bit</strong> integer.</li>
 | 
			
		||||
</ul>
 | 
			
		||||
		Reference in New Issue
	
	Block a user