← All problemsSign in

Check Equal Contribution

You have an array $arr$ of length $N$ where $arr[i]$ $=$ $(2 * i)$ $+$ $1$ for all valid values of $i$ (i.e. $0$ $<$$=$ $i$ $<$ $N$). In one operation, you can select two indices $A$ and $B$ where $0$ $<$$=$ $A$, $B$ $<$ $N$ and subtract $1$ from $arr[A]$ and add $1$ to $arr[B]$ (i.e. perform $arr[A]$ $-$$=$$1$ and $arr[B]$ $+$$=$ $1$). The goal is to make all the elements of the array $equal$.

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