< Previous
Next >
[Stack]
[Tree]
[Design]
[Binary Search Tree]
[Binary Tree]
[Iterator]
Hint 1
The inorder traversal of a BST gives us the elements in a sorted order.
Hint 2
We can use a stack to simulate the inorder traversal of the BST.
Hint 3
We can use another stack as a buffer to store numbers returned from calls to next and use this buffer whenever prev is called.