You have been invited to a party. The host wants to split the guests into two teams of exactly the same size for party games. She would rather not look up each name on a list as the guests arrive, so she plans to fix one string in advance and decide each guest's team by whether the name comes before or after that string alphabetically.
You are given the names of n guests, all different, with n even. Find the shortest string S such that exactly half of the names are less than or equal to S and the other half are greater than S. If more than one string of that shortest length works, report the alphabetically first one.
Strings are compared alphabetically. When one string is exactly the beginning of another, the shorter one comes first, so FRED comes before FREDDIE.