Solution to Cracking the Coding Interview.