offer 二叉树的镜像
/** public class TreeNode { int val = 0; TreeNode left = null; TreeNode right = null; public TreeNode(int val) { this.val = val; } } */ public class Solution { public void Mirror(TreeNode root) { getMirror(root); } public TreeNode getMirror(TreeNode root){ if (root != null){ TreeNode rightNode = root.right; root.right = getMirror(root.left); root.left = getMirror(rightNode); } return root; } }

浙公网安备 33010602011771号