mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-09 19:44:45 +08:00
@ -262,10 +262,10 @@ class Solution {
|
||||
if (root1 == null) return root2;
|
||||
if (root2 == null) return root1;
|
||||
|
||||
TreeNode newRoot = new TreeNode(root1.val + root2.val);
|
||||
newRoot.left = mergeTrees(root1.left,root2.left);
|
||||
newRoot.right = mergeTrees(root1.right,root2.right);
|
||||
return newRoot;
|
||||
root1.val += root2.val;
|
||||
root1.left = mergeTrees(root1.left,root2.left);
|
||||
root1.right = mergeTrees(root1.right,root2.right);
|
||||
return root1;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
Reference in New Issue
Block a user