Solutions to chapter 2 of Cracking the Coding Interview.