标签:binary 左右 cpp null root pac rtt 左右子树 article
该题比較简单。递归交换每个节点的左右子树就可以。
class Solution { public: TreeNode* invertTree(TreeNode* root) { if(root == NULL) return NULL; TreeNode* tmp = root -> left; root -> left = invertTree(root -> right); root -> right = invertTree(tmp); } };
标签:binary 左右 cpp null root pac rtt 左右子树 article
原文地址:http://www.cnblogs.com/jhcelue/p/6815934.html