working on some questions from "Cracking the Coding Interview, 5th Edition"