Pregunta de entrevista de Apple

invert the binary tree with the most optimal solution