//解题思路: //左右子节点互换,然后递归就ok了 public TreeNode Mirror (TreeNode pRoot) { if(pRoot == null) { return null; } TreeNode temp = pRoot.left; pRoot.left = pRoot.right; pRoot.right = temp; Mirror(pRoot.left); Mirror(pRoot.right); return pRoot; }
//解题思路: //左右子节点互换,然后递归就ok了 public TreeNode Mirror (TreeNode pRoot) { if(pRoot == null) { return null; } TreeNode temp = pRoot.left; pRoot.left = pRoot.right; pRoot.right = temp; Mirror(pRoot.left); Mirror(pRoot.right); return pRoot; }