mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
37 lines
1.5 KiB
HTML
37 lines
1.5 KiB
HTML
<p>Alice 手中有一把牌,她想要重新排列这些牌,分成若干组,使每一组的牌数都是 <code>groupSize</code> ,并且由 <code>groupSize</code> 张连续的牌组成。</p>
|
||
|
||
<p>给你一个整数数组 <code>hand</code> 其中 <code>hand[i]</code> 是写在第 <code>i</code> 张牌上的<strong>数值</strong>。如果她可能重新排列这些牌,返回 <code>true</code> ;否则,返回 <code>false</code> 。</p>
|
||
|
||
<p> </p>
|
||
|
||
<ol>
|
||
</ol>
|
||
|
||
<p><strong>示例 1:</strong></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>hand = [1,2,3,6,2,3,4,7,8], groupSize = 3
|
||
<strong>输出:</strong>true
|
||
<strong>解释:</strong>Alice 手中的牌可以被重新排列为 <code>[1,2,3],[2,3,4],[6,7,8]</code>。</pre>
|
||
|
||
<p><strong>示例 2:</strong></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>hand = [1,2,3,4,5], groupSize = 4
|
||
<strong>输出:</strong>false
|
||
<strong>解释:</strong>Alice 手中的牌无法被重新排列成几个大小为 4 的组。</pre>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>提示:</strong></p>
|
||
|
||
<ul>
|
||
<li><code>1 <= hand.length <= 10<sup>4</sup></code></li>
|
||
<li><code>0 <= hand[i] <= 10<sup>9</sup></code></li>
|
||
<li><code>1 <= groupSize <= hand.length</code></li>
|
||
</ul>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>注意:</strong>此题目与 1296 重复:<a href="https://leetcode-cn.com/problems/divide-array-in-sets-of-k-consecutive-numbers/" target="_blank">https://leetcode-cn.com/problems/divide-array-in-sets-of-k-consecutive-numbers/</a></p>
|