1296. Divide Array in Sets of K Consecutive Numbers Medium
1/**
2 * [1296] Divide Array in Sets of K Consecutive Numbers
3 *
4 * Given an array of integers nums and a positive integer k, check whether it is possible to divide this array into sets of k consecutive numbers.
5 * Return true if it is possible. Otherwise, return false.
6 *
7 * Example 1:
8 *
9 * Input: nums = [1,2,3,3,4,4,5,6], k = 4
10 * Output: true
11 * Explanation: Array can be divided into [1,2,3,4] and [3,4,5,6].
12 *
13 * Example 2:
14 *
15 * Input: nums = [3,2,1,2,3,4,3,4,5,9,10,11], k = 3
16 * Output: true
17 * Explanation: Array can be divided into [1,2,3] , [2,3,4] , [3,4,5] and [9,10,11].
18 *
19 * Example 3:
20 *
21 * Input: nums = [1,2,3,4], k = 3
22 * Output: false
23 * Explanation: Each array should be divided in subarrays of size 3.
24 *
25 *
26 * Constraints:
27 *
28 * 1 <= k <= nums.length <= 10^5
29 * 1 <= nums[i] <= 10^9
30 *
31 *
32 * Note: This question is the same as 846: <a href="https://leetcode.com/problems/hand-of-straights/" target="_blank">https://leetcode.com/problems/hand-of-straights/</a>
33 */
34pub struct Solution {}
35
36// problem: https://leetcode.com/problems/divide-array-in-sets-of-k-consecutive-numbers/
37// discuss: https://leetcode.com/problems/divide-array-in-sets-of-k-consecutive-numbers/discuss/?currentPage=1&orderBy=most_votes&query=
38
39// submission codes start here
40
41impl Solution {
42 pub fn is_possible_divide(nums: Vec<i32>, k: i32) -> bool {
43 false
44 }
45}
46
47// submission codes end
48
49#[cfg(test)]
50mod tests {
51 use super::*;
52
53 #[test]
54 fn test_1296() {
55 }
56}
57
Back
© 2025 bowen.ge All Rights Reserved.