solution to Cracking Code Interview questions