1305. All Elements in Two Binary Search Trees

https://leetcode.com/problems/all-elements-in-two-binary-search-trees

Description

Given two binary search trees root1 and root2.

Return a list containing all the integers from both trees sorted in ascending order.

Example 1:

Example 2:

Example 3:

Example 4:

Example 5:

Constraints:

  • Each tree has at most 5000 nodes.

  • Each node's value is between [-10^5, 10^5].

ac

Last updated

Was this helpful?