← All problemsSign in

E - Mex and Max

You are given a set $S$, consisting of $n$ **distinct** non-negative integers. In one move, you can perform exactly one of the following two operations: - Insert $\text{mex}(S)$ into $S$. - Delete $\max(S)$ from $S$. This can only be done if $S$ is not empty. Here, $\text{mex}(S)$ denotes the minimum excluded value of $S$, which is the smallest non-negative integer not present in $S$. For ex

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