Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 4ddb134

Browse files
committed
增加No10356
1 parent e88f0fa commit 4ddb134

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

leetcode/Tree/No1305.java

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package Algorithm.leetcode.Tree;
2+
3+
import java.util.ArrayList;
4+
import java.util.Collections;
5+
import java.util.List;
6+
7+
/**
8+
* No1305
9+
*
10+
* Created by tujietg on Jan 23, 2020
11+
*/
12+
public class No1305 {
13+
List<Integer> list = new ArrayList<Integer>();
14+
15+
public List<Integer> getAllElements(TreeNode root1, TreeNode root2) {
16+
addList(root1);
17+
addList(root2);
18+
Collections.sort(list);
19+
return list;
20+
}
21+
22+
public void addList(TreeNode node) {
23+
if (node == null) {
24+
return;
25+
}
26+
list.add(node.val);
27+
addList(node.left);
28+
addList(node.right);
29+
}
30+
31+
}

0 commit comments

Comments
 (0)