this is code for the 4th chaper of cracking code interview