You are given a permutation .
An array is called good if its indices can be partitioned into groups such that every group consists of indices , where , and .
Every index must belong to exactly one group. The indices in a group do not have to be consecutive. The empty array is considered good.
Find the minimum number of elements you must delete from so that the remaining array is not good. Deleting elements does not change the relative order of the remaining elements.
If is already not good, the answer is .
Delete the elements at positions 4, 5, and 6. The remaining array is [2, 1, 4]. Its three elements would have to form a single group, but they are not increasing.
Fewer deletions do not suffice. Think of the original positions as three pairs: (1, 2), (3, 4), and (5, 6). Elements chosen from different pairs are increasing in their original order. Any four remaining elements can be split into two groups of two, each using different pairs. Any five remaining elements can be split into a group of three and a group of two. All six elements can be split into [2, 4, 6] and [1, 3, 5].