maximum Feasible Groups
The largest number of groups for which some partition of this sample satisfies all three structural constraints.
Computed greedily: repeatedly take the shortest admissible prefix that satisfies both the size and distinct-value requirements. The greedy choice is optimal because taking the shortest valid first group leaves a suffix that contains the suffix left by any other valid choice, so no alternative can yield more groups. Because merging two adjacent valid groups yields a valid group, every group count from 1 up to this value is also feasible.