Invert a Binary Tree

Easy · Trees · about 10 minutes

Asked at Google, Amazon, Apple.

Given the root of a binary tree, mirror it — swap the left and right child of every node — and return the root.

Related guides