Coding

Iterator over a Binary Search Tree

Implement an iterator over a binary search tree.

Input: root = [7,3,15,null,null,9,20], calls: next(), hasNext(), next()

Output: 3, TRUE, 7

Explanation: The iterator yields the smallest value (3), confirms more nodes exist, then properly yields the next in-order value (7).

Was asked at

Practice this question with AI

First session is free - no credit card required.

Go Premium

More interviews, more skills, more success.

No answers yet

Be the first to share your approach to this question

Practice More Questions