请完成一个函数,输入一个二叉树,该函数输出它的镜像。
例如输入:
1 2 3 4 5
   |      4    /   \   2     7  / \   / \ 1   3 6   9
   | 
 
镜像输出:
1 2 3 4 5
   |      4    /   \   7     2  / \   / \ 9   6 3   1
   | 
 
示例
1 2
   | 输入:root = [4,2,7,1,3,6,9] 输出:[4,7,2,9,6,3,1]
   | 
 
解法
1 2 3 4 5 6 7 8 9 10 11
   | class Solution:     def mirrorTree(self, root: TreeNode) -> TreeNode:         if not root:             return None                  self.mirrorTree(root.left)         self.mirrorTree(root.right)         temp = root.left          root.left =root.right         root.right = temp         return root
   | 
 
更优雅的一种写法:
剑指 Offer 27. 二叉树的镜像(递归 / 辅助栈,清晰图解) - 二叉树的镜像 - 力扣(LeetCode) (leetcode-cn.com)
1 2 3 4 5 6 7 8 9 10
   | public TreeNode mirrorTree(TreeNode root) {         if (root == null) {             return null;         }         TreeNode leftRoot = mirrorTree(root.right);         TreeNode rightRoot = mirrorTree(root.left);         root.left = leftRoot;         root.right = rightRoot;         return root;     }
  |