← All problemsSign in

Make All Zero

CodeChefRating 1998Open on judge ↗

You have an array $A$ of size $N$. You want to convert all elements of this array into $0$. You can do $2$ types of operations: - Choose $x$ $(1 \le x \le N)$, and set $A_i = A_i - 1$, for all $1 \le i \le x$, i.e decrement prefix of length $x$ by $1$. - Note: You must not perform this type of operation if there exists $1 \le i \le x$ such that $A_i = 0$, since that element would become ne

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