Description
Given sorted array, split into one or more subsequences where each has length >= 3 and consecutive integers.
Examples
Input:
nums = [1,2,3,3,4,5]Output:
trueExplanation:
Split into [1,2,3] and [3,4,5].
Input:
nums = [1]Output:
trueExplanation:
Edge case with a single-element array.
Input:
nums = [1,2,3,4,4,5]Output:
falseExplanation:
Cannot form valid consecutive subsequences. There are [1,2,3,4] and [4,5], but the second subsequence only has length 2, which violates the minimum length requirement of 3.
Constraints
- •
1 ≤ nums.length ≤ 10⁴