← All problemsSign in

Different Replacement

CodeChefRating 3231Open on judge ↗

You're given an array $A$ of length $N$, with elements between $1$ and $N$. You will perform the following operation **exactly once**: - Choose two indices $L$ and $R$ ($1 \leq L \leq R \leq N$). - Then, choose an integer $X$ ($1 \leq X \leq N$) such that $X$ **does not appear** among $[A_L, A_{L+1}, A_{L+2}, \ldots, A_R]$. - Finally, for each $i$ from $L$ to $R$ (inclusive of both), set $A_i$ to

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