牛客网 (opens new window)
public TreeNode Mirror(TreeNode root) { if (root == null) return root; swap(root); Mirror(root.left); Mirror(root.right); return root; } private void swap(TreeNode root) { TreeNode t = root.left; root.left = root.right; root.right = t; }
← 树的子结构 对称的二叉树→