mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-10-22 05:26:46 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>给你一个整数数组 <code>nums</code> 和一个整数 <code>k</code> 。你需要将这个数组划分到 <code>k</code> 个相同大小的子集中,使得同一个子集里面没有两个相同的元素。</p>\n\n<p>一个子集的 <strong>不兼容性</strong> 是该子集里面最大值和最小值的差。</p>\n\n<p>请你返回将数组分成 <code>k</code> 个子集后,各子集 <strong>不兼容性 </strong>的<strong> 和</strong> 的 <strong>最小值</strong> ,如果无法分成分成 <code>k</code> 个子集,返回 <code>-1</code> 。</p>\n\n<p>子集的定义是数组中一些数字的集合,对数字顺序没有要求。</p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<pre>\n<b>输入:</b>nums = [1,2,1,4], k = 2\n<b>输出:</b>4\n<b>解释:</b>最优的分配是 [1,2] 和 [1,4] 。\n不兼容性和为 (2-1) + (4-1) = 4 。\n注意到 [1,1] 和 [2,4] 可以得到更小的和,但是第一个集合有 2 个相同的元素,所以不可行。</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<pre>\n<b>输入:</b>nums = [6,3,8,1,3,1,2,2], k = 4\n<b>输出:</b>6\n<b>解释:</b>最优的子集分配为 [1,2],[2,3],[6,8] 和 [1,3] 。\n不兼容性和为 (2-1) + (3-2) + (8-6) + (3-1) = 6 。\n</pre>\n\n<p><strong>示例 3:</strong></p>\n\n<pre>\n<b>输入:</b>nums = [5,3,3,6,3,3], k = 3\n<b>输出:</b>-1\n<b>解释:</b>没办法将这些数字分配到 3 个子集且满足每个子集里没有相同数字。\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 <= k <= nums.length <= 16</code></li>\n\t<li><code>nums.length</code> 能被 <code>k</code> 整除。</li>\n\t<li><code>1 <= nums[i] <= nums.length</code></li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Hard",
|
||||
"likes": 45,
|
||||
"likes": 47,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -155,7 +155,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"2.7K\", \"totalSubmission\": \"6.8K\", \"totalAcceptedRaw\": 2727, \"totalSubmissionRaw\": 6788, \"acRate\": \"40.2%\"}",
|
||||
"stats": "{\"totalAccepted\": \"2.8K\", \"totalSubmission\": \"7K\", \"totalAcceptedRaw\": 2825, \"totalSubmissionRaw\": 6979, \"acRate\": \"40.5%\"}",
|
||||
"hints": [
|
||||
"The constraints are small enough for a backtrack solution but not any backtrack solution",
|
||||
"If we use a naive n^k don't you think it can be optimized"
|
||||
|
Reference in New Issue
Block a user