root of a binary tree. Turn it into its mirror image: at every node, the left and right subtrees trade places. Return the root of the resulting tree.
If the tree is empty, return None.root=tree_node([10, 5, 20, 3, None, 15]) → [10, 20, 5, None, 15, None, 3]
Every node swaps its left and right subtrees: 20 moves to the left, 5 to the right, and 3 and 15 switch sides under their parents.
root=tree_node([1, None, 2]) → [1, 2]
The only right child becomes a left child.
root=tree_node([]) → None
An empty tree has nothing to mirror.
Node.val ≤ 100root=tree_node([10, 5, 20, 3, None, 15])
[10, 20, 5, None, 15, None, 3]
Run checks the first 3 tests in your browser. Submit checks all 72 tests on the server, hidden ones included.