Codeforces 1375D Replace by MEX - Problem Statement

CF 1375D - transform array using MEX operations

Given array aa of nn elements where 0ain0 \le a_i \le n, transform it into sorted order. Each operation: pick index ii and set ai=MEX(a)a_i = \text{MEX}(a).

Constraints: n1000n \le 1000. Use at most 2n2n operations.

MEX is the minimum non-negative integer not in the array.