← All problemsSign in

Subarray Mex

CodeChefRating 1499Open on judge ↗

Chef was on vacation when a thought struck him. Given three integers $N,K, $ and $X,$ he would like to make an array $A$ of length $N$ such that it satisfies the following conditions: - $0 \le A_i \le N$ for each $1 \le i \le N$ - The MEX of every contiguous [subarray](https://stackoverflow.com/a/45686639) of length $K$ in $A$ is $X$. Please help Chef in finding such an array. If there are multip

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