1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-07 08:21:41 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2022-05-02 23:44:12 +08:00
parent 7ea03594b3
commit 2a71c78585
4790 changed files with 11696 additions and 10944 deletions

View File

@@ -12,7 +12,7 @@
"translatedContent": "<p>给你一个整数&nbsp;<code>finalSum</code>&nbsp;。请你将它拆分成若干个&nbsp;<strong>互不相同</strong> 的正偶数之和,且拆分出来的正偶数数目&nbsp;<strong>最多</strong>&nbsp;。</p>\n\n<ul>\n\t<li>比方说,给你&nbsp;<code>finalSum = 12</code>&nbsp;,那么这些拆分是&nbsp;<strong>符合要求</strong> 的(互不相同的正偶数且和为&nbsp;<code>finalSum</code><code>(2 + 10)</code>&nbsp;<code>(2 + 4 + 6)</code>&nbsp;和&nbsp;<code>(4 + 8)</code>&nbsp;。它们中,<code>(2 + 4 + 6)</code>&nbsp;包含最多数目的整数。注意&nbsp;<code>finalSum</code>&nbsp;不能拆分成&nbsp;<code>(2 + 2 + 4 + 4)</code>&nbsp;,因为拆分出来的整数必须互不相同。</li>\n</ul>\n\n<p>请你返回一个整数数组,表示将整数拆分成 <strong>最多</strong> 数目的正偶数数组。如果没有办法将&nbsp;<code>finalSum</code>&nbsp;进行拆分,请你返回一个&nbsp;<strong>空</strong>&nbsp;数组。你可以按 <b>任意</b>&nbsp;顺序返回这些整数。</p>\n\n<p>&nbsp;</p>\n\n<p><strong>示例 1</strong></p>\n\n<pre>\n<b>输入:</b>finalSum = 12\n<b>输出:</b>[2,4,6]\n<b>解释:</b>以下是一些符合要求的拆分:<code>(2 + 10)<span style=\"\"></span></code><code>(2 + 4 + 6) </code>和 <code>(4 + 8) 。</code>\n(2 + 4 + 6) 为最多数目的整数,数目为 3 ,所以我们返回 [2,4,6] 。\n[2,6,4] [6,2,4] 等等也都是可行的解。\n</pre>\n\n<p><strong>示例 2</strong></p>\n\n<pre>\n<b>输入:</b>finalSum = 7\n<b>输出:</b>[]\n<b>解释:</b>没有办法将 finalSum 进行拆分。\n所以返回空数组。\n</pre>\n\n<p><strong>示例 3</strong></p>\n\n<pre>\n<b>输入:</b>finalSum = 28\n<b>输出:</b>[6,8,2,12]\n<b>解释:</b>以下是一些符合要求的拆分:<code>(2 + 26)<span style=\"\"></span></code><code>(6 + 8 + 2 + 12)</code> 和 <code>(4 + 24) 。</code>\n<code>(6 + 8 + 2 + 12)</code> 有最多数目的整数,数目为 4 ,所以我们返回 [6,8,2,12] 。\n[10,2,4,12] [6,2,4,16] 等等也都是可行的解。\n</pre>\n\n<p>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 &lt;= finalSum &lt;= 10<sup>10</sup></code></li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Medium",
"likes": 9,
"likes": 10,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
@@ -143,7 +143,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"5.1K\", \"totalSubmission\": \"9.3K\", \"totalAcceptedRaw\": 5106, \"totalSubmissionRaw\": 9261, \"acRate\": \"55.1%\"}",
"stats": "{\"totalAccepted\": \"5.3K\", \"totalSubmission\": \"9.7K\", \"totalAcceptedRaw\": 5344, \"totalSubmissionRaw\": 9664, \"acRate\": \"55.3%\"}",
"hints": [
"First, check if finalSum is divisible by 2. If it isnt, then we cannot split it into even integers.",
"Let k be the number of elements in our split. As we want the maximum number of elements, we should try to use the first k - 1 even elements to grow our sum as slowly as possible.",