Solution to CTCI 9.2