Pergunta de entrevista da empresa Magic

Ring all reduce. Only optimal solution is accepted.