翻转二叉树的步骤:

1.翻转根节点的左子树(递归调用当前函数)

2.翻转根节点的右子树(递归调用当前函数)

3.交换根节点的左子节点与右子节点

 class  Solution{
public:
void exchage(TreeNode *root){
TreeNode* node=root;
if (node!=NULL){
TreeNode* temp=node->left;
node ->left=node->right;
node->right=temp;
}
}
TreeNode *invertTree(TreeNode *root){
TreeNode*node=root
if (root==NULL){
return root;
}
invertTree(node->left)
invertTree(node->right)
exchange(node);
return root; }
};
05-08 07:59