← All problemsSign in

Adjacent Sums

CodeChefRating 1920Open on judge ↗

An array $A$ of size $N (N \ge 2)$, containing non-negative integers, is called *good* if all of the following conditions hold: - $A_1 = A_2$, or $A_1 = 0$ - $A_N = A_{N - 1}$, or $A_N = 0$ - $A_i = A_{i - 1} + A_{i + 1}$, or $A_i = 0$ for all $1 < i < N$. Less formally, we need all non-zero $A_i$ equal to the sum of it's adjacent elements. ---- You are given an array $A$ of size $N$, consisti

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