mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 11:43:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			54 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			54 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<p>给你两个正整数:<code>n</code> 和 <code>target</code> 。</p>
 | 
						||
 | 
						||
<p>如果数组 <code>nums</code> 满足下述条件,则称其为 <strong>美丽数组</strong> 。</p>
 | 
						||
 | 
						||
<ul>
 | 
						||
	<li><code>nums.length == n</code>.</li>
 | 
						||
	<li><code>nums</code> 由两两互不相同的正整数组成。</li>
 | 
						||
	<li>在范围 <code>[0, n-1]</code> 内,<strong>不存在 </strong>两个 <strong>不同</strong> 下标 <code>i</code> 和 <code>j</code> ,使得 <code>nums[i] + nums[j] == target</code> 。</li>
 | 
						||
</ul>
 | 
						||
 | 
						||
<p>返回符合条件的美丽数组所可能具备的 <strong>最小</strong> 和。</p>
 | 
						||
 | 
						||
<p> </p>
 | 
						||
 | 
						||
<p><strong>示例 1:</strong></p>
 | 
						||
 | 
						||
<pre>
 | 
						||
<strong>输入:</strong>n = 2, target = 3
 | 
						||
<strong>输出:</strong>4
 | 
						||
<strong>解释:</strong>nums = [1,3] 是美丽数组。
 | 
						||
- nums 的长度为 n = 2 。
 | 
						||
- nums 由两两互不相同的正整数组成。
 | 
						||
- 不存在两个不同下标 i 和 j ,使得 nums[i] + nums[j] == 3 。
 | 
						||
可以证明 4 是符合条件的美丽数组所可能具备的最小和。</pre>
 | 
						||
 | 
						||
<p><strong>示例 2:</strong></p>
 | 
						||
 | 
						||
<pre>
 | 
						||
<strong>输入:</strong>n = 3, target = 3
 | 
						||
<strong>输出:</strong>8
 | 
						||
<strong>解释:</strong>
 | 
						||
nums = [1,3,4] 是美丽数组。 
 | 
						||
- nums 的长度为 n = 3 。 
 | 
						||
- nums 由两两互不相同的正整数组成。 
 | 
						||
- 不存在两个不同下标 i 和 j ,使得 nums[i] + nums[j] == 3 。
 | 
						||
可以证明 8 是符合条件的美丽数组所可能具备的最小和。</pre>
 | 
						||
 | 
						||
<p><strong>示例 3:</strong></p>
 | 
						||
 | 
						||
<pre>
 | 
						||
<strong>输入:</strong>n = 1, target = 1
 | 
						||
<strong>输出:</strong>1
 | 
						||
<strong>解释:</strong>nums = [1] 是美丽数组。
 | 
						||
</pre>
 | 
						||
 | 
						||
<p> </p>
 | 
						||
 | 
						||
<p><strong>提示:</strong></p>
 | 
						||
 | 
						||
<ul>
 | 
						||
	<li><code>1 <= n <= 10<sup>5</sup></code></li>
 | 
						||
	<li><code>1 <= target <= 10<sup>5</sup></code></li>
 | 
						||
</ul>
 |