4.1

From The Algorithm Design Manual Solution Wiki
Jump to navigation Jump to search

Sort it with your favorite nlogn sorting algorithm. The bottom half is one team, the top half the other.

Or much better, partition it with median as pivot. Time complexity O(n).


Back to Chapter 4