代码拉取完成,页面将自动刷新
同步操作将从 小墨/力扣题库(完整版) 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
<p>There are <code>n</code> people that are split into some unknown number of groups. Each person is labeled with a <strong>unique ID</strong> from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>groupSizes</code>, where <code>groupSizes[i]</code> is the size of the group that person <code>i</code> is in. For example, if <code>groupSizes[1] = 3</code>, then person <code>1</code> must be in a group of size <code>3</code>.</p>
<p>Return <em>a list of groups such that each person <code>i</code> is in a group of size <code>groupSizes[i]</code></em>.</p>
<p>Each person should appear in <strong>exactly one group</strong>, and every person must be in a group. If there are multiple answers, <strong>return any of them</strong>. It is <strong>guaranteed</strong> that there will be <strong>at least one</strong> valid solution for the given input.</p>
<p> </p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</strong> groupSizes = [3,3,3,3,3,1,3]
<strong>Output:</strong> [[5],[0,1,2],[3,4,6]]
<b>Explanation:</b>
The first group is [5]. The size is 1, and groupSizes[5] = 1.
The second group is [0,1,2]. The size is 3, and groupSizes[0] = groupSizes[1] = groupSizes[2] = 3.
The third group is [3,4,6]. The size is 3, and groupSizes[3] = groupSizes[4] = groupSizes[6] = 3.
Other possible solutions are [[2,1,6],[5],[0,4,3]] and [[5],[0,6,2],[4,3,1]].
</pre>
<p><strong class="example">Example 2:</strong></p>
<pre>
<strong>Input:</strong> groupSizes = [2,1,3,3,3,2]
<strong>Output:</strong> [[1],[0,5],[2,3,4]]
</pre>
<p> </p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>groupSizes.length == n</code></li>
<li><code>1 <= n <= 500</code></li>
<li><code>1 <= groupSizes[i] <= n</code></li>
</ul>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。