Code I wrote for a problem in "Cracking the Coding Interview"