Search in a Binary Search Tree (LeetCode 700): Interview Notes

📅 2026-11-05T09:16:04.809Z
👁️ 53 katselukertaa
🔓 Julkinen


# Search in a Binary Search Tree (LeetCode 700): Interview Notes

## Problem
Return the subtree rooted at the node whose value equals val, or null.

## Approach
Use the BST property: if val is smaller go left, if larger go right, otherwise return the node. Write it iteratively — a simple while loop — so you avoid recursion depth concerns on a skewed tree.

## Complexity
O(h) time where h is the tree height (O(log n) balanced, O(n) skewed); O(1) space iteratively.

## Interview tip
Interviewers often follow up with insert or delete in a BST. Having the search loop clean makes those follow-ups much easier. If you want live help practicing explanations like this, see [AI coding interview assistant](https://www.linkjob.ai/coding-interview-copilot/).

*Disclosure: I work on Linkjob AI.*