LeetCode 230 ·
Medium
Kth Smallest Element in a BST
Return the kth smallest value in a BST.
Try it
Step through the core mechanic. The simulator below runs the recursion shape this problem is built on.
Walk the pattern
No dedicated step-through for this one yet. The shape is Recursion — its pattern page has the interactive walkthrough, the reference implementation, and a five-problem progression that this problem sits inside.
The approach
In-order traversal visits a BST in ascending order; stop at the kth visited node. An explicit stack lets you halt early without walking the whole tree.
| Aspect | Value |
|---|---|
| Pattern | Recursion |
| Recognise it by | In-order traversal yields sorted order. |
| Time complexity | O(h+k) |
| Space complexity | O(h) |
| Difficulty | Medium |
Who asks it
Companies known to ask this problem, from public LeetCode company-tag aggregations. A signal of where to expect it, not a guarantee.