@@ -0,0 +1,863 @@
+package leetcode;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.Collections;%0Aimport java.util.List;%0A%0A/**%0A * https://leetcode.com/problems/all-elements-in-two-binary-search-trees/%0A */%0Apublic class Problem1305 %7B%0A    public static class TreeNode %7B%0A        int val;%0A        TreeNode left;%0A        TreeNode right;%0A%0A        TreeNode(int x) %7B%0A            val = x;%0A        %7D%0A    %7D%0A%0A    public List%3CInteger%3E getAllElements(TreeNode root1, TreeNode root2) %7B%0A        List%3CInteger%3E answer = new ArrayList%3C%3E();%0A        traverse(root1, answer);%0A        traverse(root2, answer);%0A        Collections.sort(answer);%0A        return answer;%0A    %7D%0A%0A    private static void traverse(TreeNode root, List%3CInteger%3E list) %7B%0A        if (root == null) %7B%0A            return;%0A        %7D%0A        list.add(root.val);%0A        traverse(root.left, list);%0A        traverse(root.right, list);%0A    %7D%0A%7D%0A

Solve problem 1305