Mex Chef
A function $F$ is defined on an array $A$ of length $N$ as follows: $$F(A) = \sum_{i=1}^{N} MEX([A_1, A_2, \ldots, A_i])$$ For example, if $A = [2, 0, 1],$ then $F(A) = MEX([2]) + MEX([2,0])$ $ + MEX([2,0,1])$ $ = 0 +1 +3 = 4$. You are given two integers $N$ and $K$, with $N \leq K$. For each $i = N, N + 1, \dots, K$ in order, find the number of [permutations](https://en.wikipedia.org/wiki/Per
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