Chapter2 coding interview problem 2.