1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/划分数组为连续数字的集合 [divide-array-in-sets-of-k-consecutive-numbers].html
2022-03-29 12:43:11 +08:00

49 lines
1.5 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给你一个整数数组&nbsp;<code>nums</code>&nbsp;和一个正整数&nbsp;<code>k</code>,请你判断是否可以把这个数组划分成一些由&nbsp;<code>k</code>&nbsp;个连续数字组成的集合。<br />
如果可以,请返回 <code>true</code>;否则,返回 <code>false</code></p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>nums = [1,2,3,3,4,4,5,6], k = 4
<strong>输出:</strong>true
<strong>解释:</strong>数组可以分成 [1,2,3,4] 和 [3,4,5,6]。
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>nums = [3,2,1,2,3,4,3,4,5,9,10,11], k = 3
<strong>输出:</strong>true
<strong>解释:</strong>数组可以分成 [1,2,3] , [2,3,4] , [3,4,5] 和 [9,10,11]。
</pre>
<p><strong>示例 3</strong></p>
<pre>
<strong>输入:</strong>nums = [3,3,2,2,1,1], k = 3
<strong>输出:</strong>true
</pre>
<p><strong>示例 4</strong></p>
<pre>
<strong>输入:</strong>nums = [1,2,3,4], k = 3
<strong>输出:</strong>false
<strong>解释:</strong>数组不能分成几个大小为 3 的子数组。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= k &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
<li><code>1 &lt;= nums[i] &lt;= 10<sup>9</sup></code></li>
</ul>
<p>&nbsp;</p>
<p><strong>注意:</strong>此题目与 846 重复:<a href="https://leetcode-cn.com/problems/hand-of-straights/" target="_blank">https://leetcode-cn.com/problems/hand-of-straights/</a></p>