Needed one clarification regarding second test case.

1 2 1 is the given sequence. As per the question, 1 2 1 and 2 1 both are sub-sequence. As per the condition, in any sub-sequence a[i] < a[i+1]. Then both will not be AP sequence. how come ans is 1. Pls explain where i’m wrong.

I think you should first study about AP.

1 Like

2 1 is an AP… infact any sequence of two terms is always an AP

i didn’t get this part.

Sequence s[1], s[2], …, s[k] is called a subsequence of sequence a[1], a[2], …, a[n], if there will be such increasing sequence of indices i[1], i[2], …, i[k] (1 ≤ i[1] < i[2] < … < i[k] ≤ n), that a[i[j]] = s[j].

1 2 1 is a sub-sequence but not AP … that’s why the answer is 1 …