why the output of Example 3 in the question is false? Thanks!


  • 1
    K

    Hi there, I have a question about the example 3 in the question. I'm wondering why the output of [1,2,3,4,4,5] is false. I'm thinking that it can be split into two consecutive sequence as [1,2,4], [3,4,5].

    Thanks for your help!


  • 1
    S

    In [1,2,4] 2,4 are not "Consecutive"


  • 1
    S

    The same problem.

    I tested the case of "[1,2,3,4]" and the output of it is true. I think it means that when the number of the sequence is 1, the result also OK for this question.

    However, the output of "[1,2,3,4,4]" is false. But we can just split it into 1 sequence"[1,2,3,4,4]", which also satisfies the condition "each subsequences consist of at least 3 consecutive integers". Could anyone please explain it?


  • 0
    K

    @shivan4030 That makes sense. Thanks!


  • 1
    N

    @sspri You are right. 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.". The output of [1,2,3,4,4] is false, because it doesn't satisfy the first condition (it has duplicate). However, [1,2,3,4] satisfies both conditions and consequently returns true.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.