Solving the Google practice code question

Applying for a Coop position in Google without any hope that they will get back to me. It was a rainy morning...