MEXimize the Array
You are given an array $A$ of length $N$. You can do the following operation any number of times: - Select any index $i$ $(1 \le i \le N)$ and either increase $A_i$ by $1$ or decrease $A_i$ by $1$. Find the **minimum** number of operations required to make the MEX of the array maximum possible. The MEX (minimum excluded) of an array is the smallest non-negative integer that does not belong to t
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