Class Solution
java.lang.Object
g1201_1300.s1296_divide_array_in_sets_of_k_consecutive_numbers.Solution
1296 - Divide Array in Sets of K Consecutive Numbers.<p>Medium</p>
<p>Given an array of integers <code>nums</code> and a positive integer <code>k</code>, check whether it is possible to divide this array into sets of <code>k</code> consecutive numbers.</p>
<p>Return <code>true</code> <em>if it is possible</em>. Otherwise, return <code>false</code>.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> nums = [1,2,3,3,4,4,5,6], k = 4</p>
<p><strong>Output:</strong> true</p>
<p><strong>Explanation:</strong> Array can be divided into [1,2,3,4] and [3,4,5,6].</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> nums = [3,2,1,2,3,4,3,4,5,9,10,11], k = 3</p>
<p><strong>Output:</strong> true</p>
<p><strong>Explanation:</strong> Array can be divided into [1,2,3] , [2,3,4] , [3,4,5] and [9,10,11].</p>
<p><strong>Example 3:</strong></p>
<p><strong>Input:</strong> nums = [1,2,3,4], k = 3</p>
<p><strong>Output:</strong> false</p>
<p><strong>Explanation:</strong> Each array should be divided in subarrays of size 3.</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= k <= nums.length <= 10<sup>5</sup></code></li>
<li><code>1 <= nums[i] <= 10<sup>9</sup></code></li>
</ul>
<p><strong>Note:</strong> This question is the same as 846: <a href="https://leetcode.com/problems/hand-of-straights/" target="_top">https://leetcode.com/problems/hand-of-straights/</a></p>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
isPossibleDivide
public boolean isPossibleDivide(int[] nums, int k)
-