It is time to arrange the seating around a circular table for a party. We
want to alternate boys and girls around the table. We have a list of all
the attendees and their genders. Each attendee is specified by a String that
consists of the name, followed by one space, followed by either "boy" or "girl".
In addition to the attendees, we need to seat
the HOST (a boy) and the HOSTESS (a girl) with the HOSTESS directly across from
the HOST. That means that half the attendees should be on the HOST's left, and half on his right.
Create a class PartySeats that contains a method seating that is given a
String[] attendees that lists all the attendees and their genders. The method
returns a String[] that gives the seating plan, starting with "HOST" and proceeding
clockwise around the table, including all the attendees and the HOSTESS.
If there is more than one possible seating plan,
return the one that comes first lexicographically. "First lexicographically" means that each successive element in the return should be chosen to be the earliest alphabetically that is consistent with a legal seating plan. If there is no legal seating
plan, the return should contain 0 elements.
|