MEX QUERIES
Chef has a multiset $A$ where each element in the multiset $\in [0, N-1]$. In one operation, he can do either of the following on $A$: - Select an element $X$ and replace it with $2\cdot X$ - Select an element $X$ and replace it with $2\cdot X+1$ Chef wants to know the **minimum** number of operations required to make the *MEX* of $A$ equal to a given value $i$, for each $0\le i \le N$. The *ME
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