Skip to content

Commit d4095a9

Browse files
author
Joseph Luce
authored
Update 617_merge_two_binary_trees.md
1 parent c344520 commit d4095a9

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

leetcode/easy/617_merge_two_binary_trees.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ class Solution:
3939
- Space: O(N)
4040
- N = Number of elements in both trees
4141

42-
Similar to the recursion solution, however, will need to keep two items in the each element of the stack since the idea was to traverse the nodes in pairs. You could use two stacks but I believe the code would be more clunky.
42+
Similar to the recursion solution, however, we will need to keep two items in each element of the stack.
43+
Since the idea was to traverse the nodes in pairs.
44+
You could use two stacks but I believe the code would be more clunky.
4345

4446
```
4547
class Solution:
@@ -52,7 +54,7 @@ class Solution:
5254
node1, node2 = stack.pop()
5355
if node1 is None or node2 is None:
5456
continue
55-
node1.val += node2.val
57+
node1.val += node2.val # node1 is the primary tree
5658
if node2.left is not None and node1.left is None:
5759
node1.left = TreeNode(0)
5860
if node2.right is not None and node1.right is None:

0 commit comments

Comments
 (0)