Pergunta de entrevista da empresa Google

It was a coding exercise.