Chapter2 coding interview problem 1.