bugfree Icon
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course

Leetcode Problem 776. Split BST

776. Split BST

Leetcode Solutions

Recursive Split of Binary Search Tree

  1. If the root is null, return an array containing two nulls.
  2. If the root value is less than or equal to the target, include the root in the left subtree. a. Recursively split the right child with the target. b. Set the right child of the root to the left part of the split result. c. The left part of the final result is the root, and the right part is the right part of the split result.
  3. If the root value is greater than the target, include the root in the right subtree. a. Recursively split the left child with the target. b. Set the left child of the root to the right part of the split result. c. The left part of the final result is the left part of the split result, and the right part is the root.
UML Thumbnail

Iterative In-Order Traversal Split

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...