18. Mirror (Invert) a Binary Tree
EasyTrees
Convert a binary tree into its mirror image by swapping every node's left and right children. Return the root.
A binary tree is passed as TreeNode objects with val, left and right. The tests write trees in level order, with null for a missing child.
Example 1
Input: root = [4, 2, 7, 1, 3, 6, 9] Output: [4, 7, 2, 9, 6, 3, 1]
Constraints
0 ≤ nodes ≤ 100