转换左右子树,还是树的递归
public TreeNode invertTree(TreeNode root) {
if (root == null) {
return null;
}
//递归下去
TreeNode right = invertTree(root.right);
TreeNode left = invertTree(root.left);
//交换左右子树
root.left = right;
root.right = left;
return root;
}