← All problemsSign in

Distinct Integers

CodeChefRating 3178Open on judge ↗

MoEngage gives you an array $A$ of length $N$. You are required to perform **exactly** $(N-1)$ operations on the array. In one operation, you have to pick two indices $i$ and $j$ $(1 \leq i < j \leq N)$ and do the following: - Remove the elements $A_i$ and $A_j$ from array. - Append $|A_i - A_j|$ to the array. Note that, after each operation, the size of the array is reduced by one. Thus, after

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