1214. Two Sum BSTs
https://leetcode.com/problems/two-sum-bsts
Description
Given the roots of two binary search trees, root1
and root2
, 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
.
Example 1:

Example 2:

Constraints:
The number of nodes in each tree is in the range
[1, 5000]
.-109 <= Node.val, target <= 109
ac
Last updated
Was this helpful?