Search in a Binary Search Tree
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
You are given the root of a binary search tree with unique values and an integer val. Find the node whose value is val and return it; the grader reads back the entire subtree rooted at that node.
If no node has that value, return null (graded as the empty tree []). Use the ordering so each step discards one side of the tree.
Examples
Constraints
- 1 <= number of nodes <= 5000
- 1 <= Node.val <= 10^7
- All values are unique and form a valid BST.
- 1 <= val <= 10^7
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.