Two test cases:
[1,2,3,4,4,5] yields false
[1,2,3] yields true
If the original array without split can be a sub-sequence, then [1,2,3,4,4,5] can be a sub-sequence where 3 consecutive integers are present. So the result should be True.
If it's not, then how can [1,2,3] be True?
I am also confuse about the description of the problem. I thought the subsequence is constructed by a series of integers including at least 3 consecutive integers while others can be non-consecutive integers. But from the result and solution, it seems like the subsequence should only be consecutive integers.
Maybe I have missed something in the description, I think this is correct since we can split it as [1,2,3] and [4,5,6,6,8,9,9].
@dingling1 You have a good point. The problem description is unclear (or considering your examples: wrong). It says: "each subsequences consist of at least 3 consecutive integers." However, considering the test cases, it should have said: "each subsequence should satisfy both of these conditions: Firstly, all elements in the subsequence should be consecutive integers with no duplicates. Secondly, each subsequence should contain at least 3 elements." [1,2,3,4,4,5] yields false, because it doesn't satisfy the first condition. However, [1,2,3] satisfies both conditions and consequently yields true.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.