We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e88f0fa commit 4ddb134Copy full SHA for 4ddb134
leetcode/Tree/No1305.java
@@ -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