Binary Search Tree Iterator
MediumLeetCodeAdvanced Trees (BST, LCA, Tree DP)
Approach hintTry it first, then revealHide
Simulate an in-order traversal lazily with a stack holding a path of left children. next pops a node and pushes the left spine of its right subtree, which is amortised O(1) time and O(h) memory.