mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-07 00:11:41 +08:00
移除零宽空格
This commit is contained in:
@@ -7,9 +7,9 @@
|
||||
"boundTopicId": 508588,
|
||||
"title": "Minimum Incompatibility",
|
||||
"titleSlug": "minimum-incompatibility",
|
||||
"content": "<p>You are given an integer array <code>nums</code> and an integer <code>k</code>. You are asked to distribute this array into <code>k</code> subsets of <strong>equal size</strong> such that there are no two equal elements in the same subset.</p>\n\n<p>A subset's <strong>incompatibility</strong> is the difference between the maximum and minimum elements in that array.</p>\n\n<p>Return <em>the <strong>minimum possible sum of incompatibilities</strong> of the </em><code>k</code> <em>subsets after distributing the array optimally, or return </em><code>-1</code><em> if it is not possible.</em></p>\n\n<p>A subset is a group integers that appear in the array with no particular order.</p>\n\n<p> </p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong> nums = [1,2,1,4], k = 2\n<strong>Output:</strong> 4\n<strong>Explanation:</strong> The optimal distribution of subsets is [1,2] and [1,4].\nThe incompatibility is (2-1) + (4-1) = 4.\nNote that [1,1] and [2,4] would result in a smaller sum, but the first subset contains 2 equal elements.</pre>\n\n<p><strong class=\"example\">Example 2:</strong></p>\n\n<pre>\n<strong>Input:</strong> nums = [6,3,8,1,3,1,2,2], k = 4\n<strong>Output:</strong> 6\n<strong>Explanation:</strong> The optimal distribution of subsets is [1,2], [2,3], [6,8], and [1,3].\nThe incompatibility is (2-1) + (3-2) + (8-6) + (3-1) = 6.\n</pre>\n\n<p><strong class=\"example\">Example 3:</strong></p>\n\n<pre>\n<strong>Input:</strong> nums = [5,3,3,6,3,3], k = 3\n<strong>Output:</strong> -1\n<strong>Explanation:</strong> It is impossible to distribute nums into 3 subsets where no two elements are equal in the same subset.\n</pre>\n\n<p> </p>\n<p><strong>Constraints:</strong></p>\n\n<ul>\n\t<li><code>1 <= k <= nums.length <= 16</code></li>\n\t<li><code>nums.length</code> is divisible by <code>k</code></li>\n\t<li><code>1 <= nums[i] <= nums.length</code></li>\n</ul>\n",
|
||||
"content": "<p>You are given an integer array <code>nums</code> and an integer <code>k</code>. You are asked to distribute this array into <code>k</code> subsets of <strong>equal size</strong> such that there are no two equal elements in the same subset.</p>\n\n<p>A subset's <strong>incompatibility</strong> is the difference between the maximum and minimum elements in that array.</p>\n\n<p>Return <em>the <strong>minimum possible sum of incompatibilities</strong> of the </em><code>k</code> <em>subsets after distributing the array optimally, or return </em><code>-1</code><em> if it is not possible.</em></p>\n\n<p>A subset is a group integers that appear in the array with no particular order.</p>\n\n<p> </p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong> nums = [1,2,1,4], k = 2\n<strong>Output:</strong> 4\n<strong>Explanation:</strong> The optimal distribution of subsets is [1,2] and [1,4].\nThe incompatibility is (2-1) + (4-1) = 4.\nNote that [1,1] and [2,4] would result in a smaller sum, but the first subset contains 2 equal elements.</pre>\n\n<p><strong class=\"example\">Example 2:</strong></p>\n\n<pre>\n<strong>Input:</strong> nums = [6,3,8,1,3,1,2,2], k = 4\n<strong>Output:</strong> 6\n<strong>Explanation:</strong> The optimal distribution of subsets is [1,2], [2,3], [6,8], and [1,3].\nThe incompatibility is (2-1) + (3-2) + (8-6) + (3-1) = 6.\n</pre>\n\n<p><strong class=\"example\">Example 3:</strong></p>\n\n<pre>\n<strong>Input:</strong> nums = [5,3,3,6,3,3], k = 3\n<strong>Output:</strong> -1\n<strong>Explanation:</strong> It is impossible to distribute nums into 3 subsets where no two elements are equal in the same subset.\n</pre>\n\n<p> </p>\n<p><strong>Constraints:</strong></p>\n\n<ul>\n\t<li><code>1 <= k <= nums.length <= 16</code></li>\n\t<li><code>nums.length</code> is divisible by <code>k</code></li>\n\t<li><code>1 <= nums[i] <= nums.length</code></li>\n</ul>\n",
|
||||
"translatedTitle": "最小不兼容性",
|
||||
"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",
|
||||
"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": 145,
|
||||
|
Reference in New Issue
Block a user