MEX on Ranges
You are given a $0$-indexed binary string $S$ of length $N + 1$, and your task is to construct an array $A$ of length $N$ such that: - $S_X = 1$ (for $0 \le X \le N$) if and only if there exists $L$ and $R$ such that: - $1 \le L \le R \le N$ - $MEX(A[L, R]) = X$, where $A[L, R]$ denotes the subarray $[A_L, A_{L + 1}, \ldots, A_R]$, and MEX denotes the minimum non-negative integer not pres
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