Tan is a school teacher. Her manager Taru asks her to bring the maximum number of students from his class where there are at max X pair of adjacent students whose heights is not the same. In similar words Tan has to find the maximum number of students standing in ascending order of their height such that there are only X adjacent pair of students whose height are not the same.
1<=n<=1000
1<=array element <=1000
1<=X<=1000
What could be the optimal solution?