Pregunta de entrevista de Magic

Ring all reduce. Only optimal solution is accepted.