|
5 | 5 | importjava.util.ArrayList; |
6 | 6 | importjava.util.List; |
7 | 7 |
|
8 | | -/** |
9 | | - * 1214. Two Sum BSTs |
10 | | - * |
11 | | - * Given two binary search trees, |
12 | | - * return True if and only if there is a node in the first tree and a node in the second tree whose values sum up to a given integer target. |
13 | | - * |
14 | | - * Example 1: |
15 | | - * 2 1 |
16 | | - * / \ / \ |
17 | | - * 1 4 0 3 |
18 | | - * |
19 | | - * Input: root1 = [2,1,4], root2 = [1,0,3], target = 5 |
20 | | - * Output: true |
21 | | - * Explanation: 2 and 3 sum up to 5. |
22 | | - * |
23 | | - * Example 2: |
24 | | - * 0 5 |
25 | | - * / \ / \ |
26 | | - * -10 10 1 7 |
27 | | - * / \ |
28 | | - * 0 2 |
29 | | - * |
30 | | - * Input: root1 = [0,-10,10], root2 = [5,1,7,0,2], target = 18 |
31 | | - * Output: false |
32 | | - * |
33 | | - * Constraints: |
34 | | - * Each tree has at most 5000 nodes. |
35 | | - * -10^9 <= target, node.val <= 10^9 |
36 | | - * */ |
37 | 8 | publicclass_1214 { |
38 | 9 | publicstaticclassSolution1 { |
39 | 10 | publicbooleantwoSumBSTs(TreeNoderoot1,TreeNoderoot2,inttarget) { |
|