Sum to 0
You are given an integer $N$. Construct an array $A$ of size $N$, with all non-zero elements, such that the sum of elements is $0$ and that the absolute values of all elements do not exceed $3$. Formally, find an array $A$ of $N$ elements such that: - $A_1 + A_2 + \ldots + A_N = 0$ - $|A_i|$ is either $1$, $2$ or $3$. If multiple answers exist, all will be accepted. If no answer exists, print
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