← All problemsSign in

MEX-OR

CodeChefRating 1650Open on judge ↗

The *MEX* (minimum excluded) of an array is the smallest non-negative integer that does not belong to the array. For instance: - The MEX of $[2, 2, 1]$ is $0$, because $0$ does not belong to the array. - The MEX of $[3, 1, 0, 1]$ is $2$, because $0$ and $1$ belong to the array, but $2$ does not. - The MEX of $[0, 3, 1, 2]$ is 4 because $0, 1, 2$ and $3$ belong to the array, but $4$ does not. Fin

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