MEX Spectrum
You are given an array $A$ of length $N$ consisting of non-negative integers, where $0 \leq A_i \leq N$ for every $i$. In one **operation**, you may: - Choose any subarray $A[l \ldots r]$ (a contiguous segment with $1 \leq l \leq r \leq N$). - Compute $m = \mathrm{MEX}(A_l, A_{l+1}, \ldots, A_r)$. - Choose any index $i$ with $l \leq i \leq r$, and set $A_i := m$. For **every** integer $K$ from $
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