Stack
173. Binary Search Tree Iterator
Build an iterator over a BST that yields values in ascending order, next() amortised O(1) and only O(h) memory. The cheap-but-wrong answer is to flatten the whole tree into a sorted array in the…
Loading…
Build an iterator over a BST that yields values in ascending order, next() amortised O(1) and only O(h) memory. The cheap-but-wrong answer is to flatten the whole tree into a sorted array in the…
Loading…