Subarray Game
We define the *goodness* of any array $B$ of length $M$ as: $\sum_{i = 1}^{M - 1} |B_{i + 1} - B_{i}|$ (Here $|X|$ denotes the absolute value of $X$). In particular, *goodness* of any array of length $1$ is $0$. Alice and Bob have an array $A$ containing $N$ **distinct** elements and they play a game with it. Alice starts the game after which both the players make moves alternatively. In one mo
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