Having a look at the AC submissions, it appears that the solution to this problem is **(n - length of longest increasing sub-sequence)**. But how does it handle the cases like

array : 3 1 2 3

The length of longest increasing sub-sequence is 3. But we can not replace 3 by 0 as it needs to be a positive integer. So, how is the answer 1 for this case ?