MEX Permutation Difference
For a set $S$ of non-negative integers, $MEX(S)$ is defined as the smallest non-negative integer which does not appear in $S$. For a given permutation $\{P_0, P_1, P_2, \ldots, P_N\}$ of integers $0$ to $N$, we define the beauty of the permutation as $|A-B|$, where: - $A = \sum_{i = 0}^N MEX(\{P_0, P_1, P_2, \ldots, P_i\})$ - $B = \sum_{i = 0}^N MEX(\{P_N, P_{N-1}, \ldots, P_{N-i} \})$ Find any
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