Skip to content

Instantly share code, notes, and snippets.

@jianminchen
Created January 3, 2018 08:11
Show Gist options
  • Save jianminchen/bf12daa3429653e757f9f47416f9bd04 to your computer and use it in GitHub Desktop.
Save jianminchen/bf12daa3429653e757f9f47416f9bd04 to your computer and use it in GitHub Desktop.
Leetcode 617 - recursive - analysis -
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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment