It's time to line up for the team photo. We want all the team members, plus the
head coach and the two assistant coaches to be in the photo. We want the head coach
in the middle and the two assistant coaches on the two ends. But
we don't want to have much disparity in heights between adjacent people.
Let's line up to minimize the sum of the absolute height differences of
adjacent people. If there is an even number of people, the coach can go in
either center position. Create a class TeamPhoto that contains method minDiff that
takes int[] height, the heights of all the people, and returns the minimum
possible sum of adjacent absolute height differences.
height lists the coach first, then the two assistant coaches, then the team
members.
|