Started solving problem 3 of cracking the coding interview