Solution Review: Find Node

Let’s take a detailed look at the previous challenge’s solution.

We'll cover the following

Solution

We know that in a BST, the value greater than the current node value will always be present in the right subtree, and the value smaller than the current node will always be present in the left subtree. Therefore, we can find our desired key value by traversing the left and right subtree iteratively.

Solution code

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.