Fluffy and Alternating Subsequence
CodeChefOpen on judge ↗
Today, Fluffy decided to play with a sequence of integers, $a_{1}$, $a_{2}$, $\ldots$, $a_{n}$ which is coincidentally a permutation of the numbers $1$, $2$, $\ldots$, $n$. Fluffy thinks that a sequence $b_{1}$, $b_{2}$, $\ldots$, $b_{k}$ is alternating if and only if either of the following holds : - For all $i$, $b_{i} < b_{i + 1}$ if and only if $i$ is odd - For all $i$, $b_{i} < b_{i + 1}$
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start