← All problemsSign in

Mexy Array

CodeChefRating 2190Open on judge ↗

You are given an array $B$ containing $N$ integers, each of which is either $-1$ or a non-negative integer. Construct **any** integer array $A$ of length $N$ such that: - $0 \leq A_i \leq 10^9$ for every $1 \leq i \leq N$ - If $B_i \geq 0$, $A$ must satisfy $mex(A_1, A_2, \ldots, A_i) = B_i$ - Otherwise, $B_i = -1$, which means there is no constraint on $mex(A_1, A_2, \ldots, A_i)$ If there does

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