1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-05 15:31:43 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2023-09-01 19:42:45 +08:00
parent 3a7fe98f11
commit 9eb643f137
28 changed files with 16946 additions and 13994 deletions

View File

@@ -0,0 +1,52 @@
<p>You are given positive integers <code>n</code> and <code>target</code>.</p>
<p>An array <code>nums</code> is <strong>beautiful</strong> if it meets the following conditions:</p>
<ul>
<li><code>nums.length == n</code>.</li>
<li><code>nums</code> consists of pairwise <strong>distinct</strong> <strong>positive</strong> integers.</li>
<li>There doesn&#39;t exist two <strong>distinct</strong> indices, <code>i</code> and <code>j</code>, in the range <code>[0, n - 1]</code>, such that <code>nums[i] + nums[j] == target</code>.</li>
</ul>
<p>Return <em>the <strong>minimum</strong> possible sum that a beautiful array could have</em>.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</strong> n = 2, target = 3
<strong>Output:</strong> 4
<strong>Explanation:</strong> We can see that nums = [1,3] is beautiful.
- The array nums has length n = 2.
- The array nums consists of pairwise distinct positive integers.
- There doesn&#39;t exist two distinct indices, i and j, with nums[i] + nums[j] == 3.
It can be proven that 4 is the minimum possible sum that a beautiful array could have.
</pre>
<p><strong class="example">Example 2:</strong></p>
<pre>
<strong>Input:</strong> n = 3, target = 3
<strong>Output:</strong> 8
<strong>Explanation:</strong> We can see that nums = [1,3,4] is beautiful.
- The array nums has length n = 3.
- The array nums consists of pairwise distinct positive integers.
- There doesn&#39;t exist two distinct indices, i and j, with nums[i] + nums[j] == 3.
It can be proven that 8 is the minimum possible sum that a beautiful array could have.
</pre>
<p><strong class="example">Example 3:</strong></p>
<pre>
<strong>Input:</strong> n = 1, target = 1
<strong>Output:</strong> 1
<strong>Explanation:</strong> We can see, that nums = [1] is beautiful.
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 &lt;= n &lt;= 10<sup>5</sup></code></li>
<li><code>1 &lt;= target &lt;= 10<sup>5</sup></code></li>
</ul>