Search⌘ K

DIY: Binary Search Tree Iterator

Understand how to build a binary search tree iterator class that returns the next smallest element and checks for additional elements. This lesson guides you through methods for efficient in-order traversal of BSTs, enabling you to solve related coding interview problems with confidence.

Problem statement

In this challenge, you have to implement a binary search tree iterator class called BSTIterator. The iterator will be initialized by the root node of the BST. You have to implement two methods:

  • next(): This will return the next smallest number in the BST.
...