运用一个递归进行二叉树的翻转,很基本的题目。、
class Solution { public: TreeNode* invertTree(TreeNode* root) { if (root == nullptr) { return nullptr; } TreeNode*left=invertTree(root->left); TreeNode*right=invertTree(root->right); root->left=right; root->right=left; return root; } };