MAX MIN MEX
You are given an array $A$ consisting of $N$ **distinct** integers. You may rearrange the elements of $A$ to form a new array $P$ (a permutation of $A$). For this permutation $P$, construct a sequence of prefix ranges $R$ where the $i$-th element is defined as $$ R_i = \max(P_1, P_2, \dots, P_i) - \min(P_1, P_2, \dots, P_i) $$ Your goal is to **maximize** the *MEX* of the sequence $R$. The M
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