[LeetCode] Split Array into Consecutive Subsequences 将数组分割成连续子序列

Posted Grandyang

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[LeetCode] Split Array into Consecutive Subsequences 将数组分割成连续子序列相关的知识,希望对你有一定的参考价值。

 

You are given an integer array sorted in ascending order (may contain duplicates), you need to split them into several subsequences, where each subsequences consist of at least 3 consecutive integers. Return whether you can make such a split.

Example 1:

Input: [1,2,3,3,4,5]
Output: True
Explanation:
You can split them into two consecutive subsequences : 
1, 2, 3
3, 4, 5

 

Example 2:

Input: [1,2,3,3,4,4,5,5]
Output: True
Explanation:
You can split them into two consecutive subsequences : 
1, 2, 3, 4, 5
3, 4, 5

 

Example 3:

Input: [1,2,3,4,4,5]
Output: False

 

Note:

  1. The length of the input is in range of [1, 10000]

 

s

 

 

 

以上是关于[LeetCode] Split Array into Consecutive Subsequences 将数组分割成连续子序列的主要内容,如果未能解决你的问题,请参考以下文章

LeetCode 842. Split Array into Fibonacci Sequence

[Leetcode] Split Array Largest Sum

[Leetcode] Split Array Largest Sum

**Leetcode 659. Split Array into Consecutive Subsequences

Leetcode 410. Split Array Largest Sum

leetcode 410. Split Array Largest Sum