Solution to CTCI 9.4
Solution to CTCI 9.5