A Peculiar Arrangement
Chef is given an array $A = [A_1, A_2, \ldots, A_N]$ of size $N$. He considers an array $A$ to be $Good$ if no two adjacent elements of $A$ are equal $($i.e $A_i \neq A_{i+1}$ for all $1\leq imax\{A_{i-1}, A_{i+1}\}$. \ Note that the indices $1$ and $N$ can neither be a local maximum nor a local minimum. Chef can perform the following two operations on the array any number of times: - Choose two
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