You are given an integer array of length \(N\). You have to find \(MEX\) of \(i^{th}\) element for all \(1 \leq i \leq N\).
\(MEX\) of the \(i^{th}\) element is the minimum element greater than or equal to \(0\) which is not present in array till the \(i^{th}\) index.
Input Format:
First line contains an integer \(N\) denoting the size of array.
Next line contains \(N\) integers denoting the elements of the array.
Output Format:
Print \(N\) integers. \(i^{th}\) element should be the \(MEX\) of the array prefix till \(i\)
Constraints:
For first test case mex of first index is 0. As it is note present in array
mex of second index is 2 as 0 and 1 is present in array.
mex of 3rd, 4th and 5th index is 2.
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor