← All problemsSign in

Minimize Maximum Mex

CodeChefRating 1847Open on judge ↗

The MEX of an array of integers is defined to be the smallest **non-negative integer** not present in it. For example, $\text{MEX}([2, 3, 1, 2]) = 0$ and $\text{MEX}([2, 0, 3]) = 1$. You are given two arrays $A$ and $B$, both of length $N$. You can perform the following operation on the arrays: - Choose an index $i$ ($1 \leq i \leq N$), and swap $A_i$ with $B_i$. Find the minimum possible va

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