Solution to Cracking the Coding Interview in c/c++