排列 mex 与 min 转化

对于一个排列,前缀 mex 的询问,可以转换为后缀最小值:

\[ \operatorname{mex}_{i = 1}^ja_i = \min_{i = j + 1}^n \limits{a_i} \]