mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 19:53:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			17 lines
		
	
	
		
			479 B
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			17 lines
		
	
	
		
			479 B
		
	
	
	
		
			HTML
		
	
	
	
	
	
<p>给定一个非空整数数组,找到使所有数组元素相等所需的最小移动数,其中每次移动可将选定的一个元素加1或减1。 您可以假设数组的长度最多为10000。</p>
 | 
						||
 | 
						||
<p><strong>例如:</strong></p>
 | 
						||
 | 
						||
<pre>
 | 
						||
<strong>输入:</strong>
 | 
						||
[1,2,3]
 | 
						||
 | 
						||
<strong>输出:</strong>
 | 
						||
2
 | 
						||
 | 
						||
<strong>说明:
 | 
						||
</strong>只有两个动作是必要的(记得每一步仅可使其中一个元素加1或减1): 
 | 
						||
 | 
						||
[1,2,3]  =>  [2,2,3]  =>  [2,2,2]
 | 
						||
</pre>
 |