problem 3 copied from white board solution whih matched with the ctci book