← All problemsSign in

H - Unpredictable Array

Value of an array is defined as the sum of the absolute differences between pairs of consecutive elements in the array. Formally, for a given array $A = \{A_1, A_2, A_3, \dots, A_n\}$, $$ \text{value}(A) = |A_1 - A_2| + |A_2 - A_3| + |A_3 - A_4| + \dots + |A_{n-1} - A_n| $$ where $|x|$ means the absolute value of $x$. You will be given an array $A$ of $n$ integers and $q$ updates. Each update

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.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start