/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
public:
TreeNode* invertTree(TreeNode* root) {
if(root==NULL)
return root;
else{
TreeNode* tmp=invertTree(root->left);
root->left=invertTree(root->right);
root->right=tmp;
return root;
}
}
};
Invert Binary Tree
最新推荐文章于 2022-11-04 16:22:05 发布