implement code in the book -- cracking the code interview