O61

Split Array into Consecutive Subsequences

Mid / Senior Engineer
Target Time: 25 - 35 Minutes
Type: BOOLEAN

Problem Statement & Objective

Determine if you can split array into one or more subsequences such that each is consecutive and length >= 3.

Function Signature (Python)

split_array_into_consecutive_subsequences(hand: list[int], group_size: int) -> bool

Input & Output Contract

Output Rule:True veya False.

System Constraints

1 <= el.length <= 10^4
0 <= el[i] <= 10^9
1 <= grup_boyutu <= el.length

Example Execution Walkthrough

el = [1, 2, 3, 6, 2, 3, 4, 7, 8], grup_boyutu = 3
[1, 2, 3], [2, 3, 4], [6, 7, 8] -> True

Example Test Scenarios (3)

Example 1: Valid
Input:[[1,2,3,6,2,3,4,7,8],3]
Expected Output:true
Example 2: 5 eleman 4'e bölünmez
Input:[[1,2,3,4,5],4]
Expected Output:false
Example 3: İki Tam Grup
Input:[[1,1,2,2,3,3],3]
Expected Output:true
Loading Python Editor...
Input Parameters
[
  [
    1,
    2,
    3,
    6,
    2,
    3,
    4,
    7,
    8
  ],
  3
]
Expected Output
true