PerMEXuation
You are given an integer $N$ and a ($0$-indexed) binary string $A$ having length $N+1$. Find any permutation $P$ of ${0,1,2,...,N-1}$ (or determine that it does not exist) that satisfies the following conditions for all $i$ ($0 \le i \le N$): - if $A_i = 0$: No contiguous segment of $P$ has $\texttt{mex}$ equal to $i$ - if $A_i = 1$: There exists at least one contiguous segment of $P$ that has
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