|
6 | 6 | import java.util.Collections; |
7 | 7 | import java.util.List; |
8 | 8 |
|
9 | | -/** |
10 | | - * 1305. All Elements in Two Binary Search Trees |
11 | | - * |
12 | | - * Given two binary search trees root1 and root2. |
13 | | - * Return a list containing all the integers from both trees sorted in ascending order. |
14 | | - * |
15 | | - * Example 1: |
16 | | - * Input: root1 = [2,1,4], root2 = [1,0,3] |
17 | | - * Output: [0,1,1,2,3,4] |
18 | | - * |
19 | | - * Example 2: |
20 | | - * Input: root1 = [0,-10,10], root2 = [5,1,7,0,2] |
21 | | - * Output: [-10,0,0,1,2,5,7,10] |
22 | | - * |
23 | | - * Example 3: |
24 | | - * Input: root1 = [], root2 = [5,1,7,0,2] |
25 | | - * Output: [0,1,2,5,7] |
26 | | - * |
27 | | - * Example 4: |
28 | | - * Input: root1 = [0,-10,10], root2 = [] |
29 | | - * Output: [-10,0,10] |
30 | | - * |
31 | | - * Example 5: |
32 | | - * Input: root1 = [1,null,8], root2 = [8,1] |
33 | | - * Output: [1,1,8,8] |
34 | | - * |
35 | | - * Constraints: |
36 | | - * Each tree has at most 5000 nodes. |
37 | | - * Each node's value is between [-10^5, 10^5].*/ |
38 | 9 | public class _1305 { |
39 | 10 | public static class Solution1 { |
40 | 11 | public List<Integer> getAllElements(TreeNode root1, TreeNode root2) { |
|
0 commit comments