题目描述
二叉树的镜像定义:源二叉树
8
/
6 10
/ /
5 7 9 11
镜像二叉树
8
/
10 6
/ /
11 9 7 5
解题思路
public class Solution { public void Mirror(TreeNode root) { if(root == null) return; swap(root); Mirror(root.left); Mirror(root.right); } public void swap(TreeNode root) { TreeNode t = root.left; root.left = root.right; root.right = t; } }