File tree 1 file changed +0
-27
lines changed
src/main/java/com/fishercoder/solutions
1 file changed +0
-27
lines changed Original file line number Diff line number Diff line change 2
2
3
3
import com .fishercoder .common .classes .TreeNode ;
4
4
5
- /**
6
- * 617. Merge Two Binary Trees
7
- *
8
- * Given two binary trees and imagine that when you put one of them to cover the other,
9
- * some nodes of the two trees are overlapped while the others are not.
10
- You need to merge them into a new binary tree.
11
- The merge rule is that if two nodes overlap,
12
- then sum node values up as the new value of the merged node.
13
- Otherwise, the NOT null node will be used as the node of new tree.
14
-
15
- Example 1:
16
- Input:
17
- Tree 1 Tree 2
18
- 1 2
19
- / \ / \
20
- 3 2 1 3
21
- / \ \
22
- 5 4 7
23
- Output:
24
- Merged tree:
25
- 3
26
- / \
27
- 4 5
28
- / \ \
29
- 5 4 7
30
- Note: The merging process must start from the root nodes of both trees.
31
- */
32
5
public class _617 {
33
6
34
7
public static class Solution1 {
You can’t perform that action at this time.
0 commit comments