solution for Cracking the coding interview