Get best answers to any doubt/query/question related to programming , jobs, gate, internships and tech-companies. Feel free to ask a question and you will receive the best advice/suggestion related to anything you ask about software-engineering , development and programming problems .

1 like 0 dislike
1,404 views
in Online Assessments by Expert (144,420 points)

1 Answer

0 like 0 dislike
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?

 

e.g
arr[]={1,1,2,3}
X=1

 

ans=3
we can take 1,1,2 or 1,1,3
by Expert (144,420 points)
...