4 line cpp using recursion


#1

if(!root1 && !root2)return NULL;
TreeNode *root = new TreeNode((root1==NULL?0:root1->val)+(root2==NULL?0:root2->val));
root->left = solve((root1==NULL?NULL:root1->left),(root2==NULL?NULL:root2->left));
root->right = solve((root1==NULL?NULL:root1->right),(root2==NULL?NULL:root2->right));
return root;