mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 19:53:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			33 lines
		
	
	
		
			962 B
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			33 lines
		
	
	
		
			962 B
		
	
	
	
		
			HTML
		
	
	
	
	
	
<p>给你一个长度为 <code>n</code> 的整数数组 <code>nums</code><em> </em>和 一个目标值 <code>target</code>。请你从 <code>nums</code><em> </em>中选出三个整数,使它们的和与 <code>target</code> 最接近。</p>
 | 
						||
 | 
						||
<p>返回这三个数的和。</p>
 | 
						||
 | 
						||
<p>假定每组输入只存在恰好一个解。</p>
 | 
						||
 | 
						||
<p> </p>
 | 
						||
 | 
						||
<p><strong>示例 1:</strong></p>
 | 
						||
 | 
						||
<pre>
 | 
						||
<strong>输入:</strong>nums = [-1,2,1,-4], target = 1
 | 
						||
<strong>输出:</strong>2
 | 
						||
<strong>解释:</strong>与 target 最接近的和是 2 (-1 + 2 + 1 = 2) 。
 | 
						||
</pre>
 | 
						||
 | 
						||
<p><strong>示例 2:</strong></p>
 | 
						||
 | 
						||
<pre>
 | 
						||
<strong>输入:</strong>nums = [0,0,0], target = 1
 | 
						||
<strong>输出:</strong>0
 | 
						||
</pre>
 | 
						||
 | 
						||
<p> </p>
 | 
						||
 | 
						||
<p><strong>提示:</strong></p>
 | 
						||
 | 
						||
<ul>
 | 
						||
	<li><code>3 <= nums.length <= 1000</code></li>
 | 
						||
	<li><code>-1000 <= nums[i] <= 1000</code></li>
 | 
						||
	<li><code>-10<sup>4</sup> <= target <= 10<sup>4</sup></code></li>
 | 
						||
</ul>
 |