/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* struct TreeNode *left;
* struct TreeNode *right;
* };
*/
struct TreeNode* invertTree(struct TreeNode* root){
if (root == NULL)
return NULL;
//由于右子树链接会被覆盖 所以先把右子树根节点存起来
struct TreeNode* right = root->right;
//先将左子树翻转后 根节点right链向翻转后的左子树
root->right = invertTree(root->left);
//再将右子树翻转后 根节点left链向翻转后的右子树
root->left = invertTree(right);
return root;
}