```
class Solution {
public:
TreeNode* mergeTrees(TreeNode* t1, TreeNode* t2) {
TreeNode *root=t1 ? (t2 ?
new TreeNode(t1->val + t2->val) :new TreeNode(t1->val)) :(t2 ? new TreeNode(t2->val) : NULL);
t1 ?(t2 ? (root->left = mergeTrees(t1->left, t2->left), root->right = mergeTrees(t1->right, t2->right)) : (root->left = t1->left, root->right = t1->right)) :(t2 ? (root->left = t2->left, root->right = t2->right ): NULL);
return root;
}
};
```