Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions solution/0600-0699/0617.Merge Two Binary Trees/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,11 @@ function mergeTrees(
root1: TreeNode | null,
root2: TreeNode | null,
): TreeNode | null {
if (root1 == null && root2 == null) return null;
if (root1 == null) return root2;
if (root2 == null) return root1;
let left = mergeTrees(root1.left, root2.left);
let right = mergeTrees(root1.right, root2.right);
if (root1 === null && root2 === null) return null;
if (root1 === null) return root2;
if (root2 === null) return root1;
const left = mergeTrees(root1.left, root2.left);
const right = mergeTrees(root1.right, root2.right);
return new TreeNode(root1.val + root2.val, left, right);
}
```
Expand Down
10 changes: 5 additions & 5 deletions solution/0600-0699/0617.Merge Two Binary Trees/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,11 @@ function mergeTrees(
root1: TreeNode | null,
root2: TreeNode | null,
): TreeNode | null {
if (root1 == null && root2 == null) return null;
if (root1 == null) return root2;
if (root2 == null) return root1;
let left = mergeTrees(root1.left, root2.left);
let right = mergeTrees(root1.right, root2.right);
if (root1 === null && root2 === null) return null;
if (root1 === null) return root2;
if (root2 === null) return root1;
const left = mergeTrees(root1.left, root2.left);
const right = mergeTrees(root1.right, root2.right);
return new TreeNode(root1.val + root2.val, left, right);
}
```
Expand Down
10 changes: 5 additions & 5 deletions solution/0600-0699/0617.Merge Two Binary Trees/Solution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ function mergeTrees(
root1: TreeNode | null,
root2: TreeNode | null,
): TreeNode | null {
if (root1 == null && root2 == null) return null;
if (root1 == null) return root2;
if (root2 == null) return root1;
let left = mergeTrees(root1.left, root2.left);
let right = mergeTrees(root1.right, root2.right);
if (root1 === null && root2 === null) return null;
if (root1 === null) return root2;
if (root2 === null) return root1;
const left = mergeTrees(root1.left, root2.left);
const right = mergeTrees(root1.right, root2.right);
return new TreeNode(root1.val + root2.val, left, right);
}