Cracking code interview problem 1.1