class Solution {
public:
TreeNode* mergeTrees(TreeNode* t1, TreeNode* t2) {
if(t1==NULL) return t2;
if(t2==NULL) return t1;
t1->val +=t2->val;
t1->left=mergeTrees(t1->left,t2->left);
t1->right=mergeTrees(t1->right,t2->right);
return t1;
}
};
二叉树归并:t1不存在,则返回t2,;t2不存在,则返回t1;否则,就把两个当前节点相加,左右子节点分别递归调用即可。