Class Solution

  • All Implemented Interfaces:

    
    public final class Solution
    
                        

    1305 - All Elements in Two Binary Search Trees.

    Medium

    Given two binary search trees root1 and root2, return a list containing all the integers from both trees sorted in ascending order.

    Example 1:

    Input: root1 = 2,1,4, root2 = 1,0,3

    Output: 0,1,1,2,3,4

    Example 2:

    Input: root1 = 1,null,8, root2 = 8,1

    Output: 1,1,8,8

    Constraints:

    • The number of nodes in each tree is in the range [0, 5000].

    • <code>-10<sup>5</sup><= Node.val <= 10<sup>5</sup></code>

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      Solution()
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final List<Integer> getAllElements(TreeNode root1, TreeNode root2)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait