Skip to content

Commit 98f4c9d

Browse files
authored
feat: update ts solution to lc problem: No.0617 (doocs#1441)
1 parent 44f61f5 commit 98f4c9d

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

solution/0600-0699/0617.Merge Two Binary Trees/README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,11 @@ function mergeTrees(
188188
root1: TreeNode | null,
189189
root2: TreeNode | null,
190190
): TreeNode | null {
191-
if (root1 == null && root2 == null) return null;
192-
if (root1 == null) return root2;
193-
if (root2 == null) return root1;
194-
let left = mergeTrees(root1.left, root2.left);
195-
let right = mergeTrees(root1.right, root2.right);
191+
if (root1 === null && root2 === null) return null;
192+
if (root1 === null) return root2;
193+
if (root2 === null) return root1;
194+
const left = mergeTrees(root1.left, root2.left);
195+
const right = mergeTrees(root1.right, root2.right);
196196
return new TreeNode(root1.val + root2.val, left, right);
197197
}
198198
```

solution/0600-0699/0617.Merge Two Binary Trees/README_EN.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,11 @@ function mergeTrees(
169169
root1: TreeNode | null,
170170
root2: TreeNode | null,
171171
): TreeNode | null {
172-
if (root1 == null && root2 == null) return null;
173-
if (root1 == null) return root2;
174-
if (root2 == null) return root1;
175-
let left = mergeTrees(root1.left, root2.left);
176-
let right = mergeTrees(root1.right, root2.right);
172+
if (root1 === null && root2 === null) return null;
173+
if (root1 === null) return root2;
174+
if (root2 === null) return root1;
175+
const left = mergeTrees(root1.left, root2.left);
176+
const right = mergeTrees(root1.right, root2.right);
177177
return new TreeNode(root1.val + root2.val, left, right);
178178
}
179179
```

solution/0600-0699/0617.Merge Two Binary Trees/Solution.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ function mergeTrees(
1616
root1: TreeNode | null,
1717
root2: TreeNode | null,
1818
): TreeNode | null {
19-
if (root1 == null && root2 == null) return null;
20-
if (root1 == null) return root2;
21-
if (root2 == null) return root1;
22-
let left = mergeTrees(root1.left, root2.left);
23-
let right = mergeTrees(root1.right, root2.right);
19+
if (root1 === null && root2 === null) return null;
20+
if (root1 === null) return root2;
21+
if (root2 === null) return root1;
22+
const left = mergeTrees(root1.left, root2.left);
23+
const right = mergeTrees(root1.right, root2.right);
2424
return new TreeNode(root1.val + root2.val, left, right);
2525
}

0 commit comments

Comments
 (0)