Skip to content

Practice Split Array into Consecutive Subsequences

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#659
LeetCode Problem

Split Array into Consecutive Subsequences

Problem Statement

Return whether the nondecreasing array nums can be partitioned into one or more subsequences, each containing at least three elements and increasing by exactly one at every step. Use every occurrence in exactly one subsequence and preserve its original order. Different subsequences may contain equal values from different positions.

Source: Split Array into Consecutive Subsequences on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [1,2,3,3,4,5]
Output
true

# Example 2

Input
nums = [1,2,3,3,4,4,5,5]
Output
true

# Example 3

Input
nums = [1,2,3,4,4,5]
Output
false

Constraints

1 <= nums.length <= 10^4
-1000 <= nums[i] <= 1000
nums is sorted in non-decreasing order.

Related LeetCode Problems

Practice more problems similar to Split Array into Consecutive Subsequences.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.