Workout from Algorithms by Robert Sedgewick