skpro19's blog

By skpro19, history, 5 years ago, In English

This is the problem .

According to the accepted solution of other coders, the following test case gives a "Yes". But, shouldn't it give a "No" ?

6 1 2 1 1 1 1 1 1 6

Any help would be really appreciated.

  • Vote: I like it
  • -10
  • Vote: I do not like it

5 years ago, # |
  Vote: I like it +1 Vote: I do not like it

Note that the non-decreasing and the non-increasing sequences are also considered ladders.

  • »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Yeah, I understand that.

    But the given query is on the range of [1, 6]. In that range, the sequence is [2, 1, 1, 1, 1, 1].

    So, it is decreasing, and then non-decreasing/non- increasing. Hence, this doesn't qualify as a ladder.

    Because the question says, it should satisfy either of the three criteria:

    1. It first doesn't decrease, and then doesn't increase.
    2. It doesn't decrease
    3. It doesn't increase.

    But, the given is decreasing and then non- decreasing. Hence, it doesn't qualify in either of the three criteria.