Pergunta de entrevista da empresa Google

Only algorithm problems are involved