Pergunta de entrevista da empresa Google

mathematical question. it was implementation based