30:00
You are given the root of a binary search tree (BST) and an integer val.
root
val
Find the node whose value equals val and return the subtree rooted at that node. If no node holds val, return null (shown as []).
null
[]
The number of nodes in the tree is in the range [1,5000][1, 5000][1,5000].
1≤Node.val≤1071 \leq \text{Node.val} \leq 10^71≤Node.val≤107
root is a binary search tree.
1≤val≤1071 \leq \text{val} \leq 10^71≤val≤107
Run code to see results.
Look for 2. In sorted order every one of the 5 values is still a candidate.
Same values in sorted order (in-order). Each move throws away one side.
Given the root of a binary search tree and a value, return the subtree rooted at the node holding that value, or null if no node has it.